12 Replies - 2051 Views - Last Post: 09 February 2010 - 09:04 PM Rate Topic: -----

#1 BlakeRey  Icon User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • Posts: 23
  • Joined: 08-February 10

Help with Java.

Posted 08 February 2010 - 02:55 PM

I seem to be having troubles with this, could anyone help me.

This is the error:

ServerDialog.java:224: not a statement
    ServerDialog.5 local5 = new Object(localJTextField, localHashMap, localJList
1, localJList2, localJList3)
    ^
ServerDialog.java:224: ';' expected
    ServerDialog.5 local5 = new Object(localJTextField, localHashMap, localJList
1, localJList2, localJList3)
                ^
ServerDialog.java:246: not a statement
    ServerDialog.6 local6 = new MouseAdapter(paramMain, paramMainApplet, localJT
extField)
    ^
ServerDialog.java:246: ';' expected
    ServerDialog.6 local6 = new MouseAdapter(paramMain, paramMainApplet, localJT
extField)
                ^
4 errors



Here is the ServerDialog.java

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import javax.swing.AbstractListModel;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRootPane;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

public class ServerDialog extends JDialog
{
  private static final String[] PARAMETERS = { "username", "sessionid", "loadmap_user", "loadmap_id", "server", "port", "mppass", "haspaid" };
  public String currentUrl;

  public ServerDialog(Main paramMain, MainApplet paramMainApplet, String paramString)
  {
    goForIt(paramMain, paramMainApplet, paramString);
  }

  public ServerDialog(Main paramMain, MainApplet paramMainApplet) {
    super(paramMain, "Select a Server", true);
    Map localMap1;
    Map localMap2;
    Map localMap3;
    try
    {
      localMap1 = parseMaps(getPage("http://www.minecraft.net/", paramMain.getLoginCookie()));
      localMap2 = parseServers(getPage("http://www.minecraft.net/servers.jsp", paramMain.getLoginCookie()));
      localMap3 = Main.getBookmarks();
    }
    catch (IOException localIOException)
    {
      JOptionPane.showMessageDialog(this, "Could not retrieve server list. Going single-player.");

      return;
    }

    HashMap localHashMap = new HashMap();

    localHashMap.put("maps", localMap1);
    localHashMap.put("servers", localMap2);
    localHashMap.put("bookmarks", localMap3);

    JPanel localJPanel = new JPanel();

    localJPanel.setLayout(new BoxLayout(localJPanel, 1));
    localJPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    JTextField localJTextField = new JTextField(50);

    Box localBox = Box.createHorizontalBox();
    localBox.add(new JLabel("Your Maps:"));
    localBox.add(Box.createHorizontalGlue());
    localJPanel.add(localBox);

    localJPanel.add(Box.createVerticalStrut(5));
    JList localJList1;
    localJPanel.add(new JScrollPane(localJList1 = new JList(localMap1.keySet().toArray())));
    localJList1.setName("maps");
    localJList1.setSelectionMode(0);

    localJPanel.add(Box.createVerticalStrut(5));

    localBox = Box.createHorizontalBox();
    localBox.add(new JLabel("Servers:"));
    localBox.add(Box.createHorizontalGlue());
    localJPanel.add(localBox);

    localJPanel.add(Box.createVerticalStrut(5));
    JList localJList2;
    localJPanel.add(new JScrollPane(localJList2 = new JList(localMap2.keySet().toArray())));
    localJList2.setName("servers");
    localJList2.setSelectionMode(0);

    localJPanel.add(Box.createVerticalStrut(5));

    localBox = Box.createHorizontalBox();
    localBox.add(new JLabel("Bookmarks:"));
    localBox.add(Box.createHorizontalGlue());
    JButton localJButton1;
    localBox.add(localJButton1 = new JButton("Add"));
    localBox.add(Box.createHorizontalStrut(5));
    JButton localJButton2;
    localBox.add(localJButton2 = new JButton("Edit"));
    localBox.add(Box.createHorizontalStrut(5));
    JButton localJButton3;
    localBox.add(localJButton3 = new JButton("Delete"));
    localJPanel.add(localBox);

    localJPanel.add(Box.createVerticalStrut(5));
    ServerDialog.BookmarkListModel localBookmarkListModel;
    JList localJList3;
    localJPanel.add(new JScrollPane(localJList3 = new JList(localBookmarkListModel = new ServerDialog.BookmarkListModel(localMap3))));
    localJList3.setName("bookmarks");
    localJList3.setSelectionMode(0);

    localJPanel.add(Box.createVerticalStrut(5));

    localBox = Box.createHorizontalBox();
    localBox.add(new JLabel("<html>Choose a server above or paste a <code>play.jsp</code> URL below. Leave blank to generate a level.</html>"));
    localBox.add(Box.createHorizontalGlue());
    localJPanel.add(localBox);

    localJPanel.add(Box.createVerticalStrut(5));

    localBox = Box.createHorizontalBox();
    localBox.add(new JLabel("URL:"));
    localBox.add(Box.createHorizontalStrut(5));
    localBox.add(localJTextField);
    localJPanel.add(localBox);

    localJPanel.add(Box.createVerticalStrut(5));

    localBox = Box.createHorizontalBox();
    localBox.add(Box.createHorizontalGlue());
    JButton localJButton4;
    localBox.add(localJButton4 = new JButton("Go!"));
    localBox.add(Box.createHorizontalGlue());
    localJPanel.add(localBox);

    localJButton1.addActionListener(new ActionListener(localJButton1, localMap3, localBookmarkListModel, localJList3)
    {
      public void actionPerformed(ActionEvent paramActionEvent)
      {
        String str1;
        do
        {
          str1 = JOptionPane.showInputDialog(this.val$addButton, "Enter a name for the bookmark:");

          if ((str1 != null) && (this.val$bookmarks.containsKey(str1)))
            JOptionPane.showMessageDialog(this.val$addButton, "That name is already in use. Please choose another."); 
        }
        while ((str1 != null) && (!(str1.isEmpty())) && (this.val$bookmarks.containsKey(str1)));

        if ((str1 == null) || (str1.isEmpty())) {
          return;
        }
        String str2;
        do
          str2 = JOptionPane.showInputDialog(this.val$addButton, "Enter the URL for the bookmark:");
        while ((str2 != null) && (str2.isEmpty()));

        if (str2 == null) {
          return;
        }
        this.val$bookmarks.put(str1, str2);
        this.val$bookmarkListModel.add(str1);
        this.val$bookmarkList.clearSelection();
        Main.saveBookmark(str1, str2);
      }
    });
    localJButton2.addActionListener(new ActionListener(localJList3, localBookmarkListModel, localMap3, localJButton1)
    {
      public void actionPerformed(ActionEvent paramActionEvent)
      {
        int i = this.val$bookmarkList.getSelectedIndex();

        if ((i < 0) || (i >= this.val$bookmarkListModel.getSize())) {
          return;
        }
        String str1 = (String)this.val$bookmarkListModel.getElementAt(i);
        String str2 = (String)this.val$bookmarks.get(str1);
        do
        {
          str2 = JOptionPane.showInputDialog(this.val$addButton, "Enter the URL for the bookmark:", str2); }
        while ((str2 != null) && (str2.isEmpty()));

        if (str2 == null) {
          return;
        }
        this.val$bookmarks.put(str1, str2);
        this.val$bookmarkList.clearSelection();
        Main.saveBookmark(str1, str2);
      }
    });
    localJButton3.addActionListener(new ActionListener(localJList3, localBookmarkListModel, localMap3)
    {
      public void actionPerformed(ActionEvent paramActionEvent)
      {
        int i = this.val$bookmarkList.getSelectedIndex();

        if ((i < 0) || (i >= this.val$bookmarkListModel.getSize())) {
          return;
        }
        String str = (String)this.val$bookmarkListModel.getElementAt(i);

        this.val$bookmarks.remove(str);
        this.val$bookmarkListModel.remove(i);
        this.val$bookmarkList.clearSelection();
        Main.saveBookmark(str, null);
      }
    });
    localJButton4.addActionListener(new ActionListener(paramMain, paramMainApplet, localJTextField)
    {
      public void actionPerformed(ActionEvent paramActionEvent) {
        ServerDialog.this.goForIt(this.val$main, this.val$applet, this.val$textField.getText());
      }

    });
    ServerDialog.5 local5 = new Object(localJTextField, localHashMap, localJList1, localJList2, localJList3)
    {
      public void valueChanged(ListSelectionEvent paramListSelectionEvent)
      {
        JList localJList = (JList)paramListSelectionEvent.getSource();
        Object localObject = localJList.getSelectedValue();

        if (localObject == null) {
          return;
        }
        this.val$textField.setText((String)((Map)this.val$lists.get(localJList.getName())).get(localObject));

        if (!(localJList.equals(this.val$mapList)))
          this.val$mapList.clearSelection();
        if (!(localJList.equals(this.val$serverList)))
          this.val$serverList.clearSelection();
        if (!(localJList.equals(this.val$bookmarkList))) {
          this.val$bookmarkList.clearSelection();
        }
      }

    };
    ServerDialog.6 local6 = new MouseAdapter(paramMain, paramMainApplet, localJTextField)
    {
      public void mouseClicked(MouseEvent paramMouseEvent)
      {
        if (paramMouseEvent.getClickCount() == 2)
          ServerDialog.this.goForIt(this.val$main, this.val$applet, this.val$textField.getText());
      }
    };
    localJList1.addListSelectionListener(local5);
    localJList1.addMouseListener(local6);

    localJList2.addListSelectionListener(local5);
    localJList2.addMouseListener(local6);

    localJList3.addListSelectionListener(local5);
    localJList3.addMouseListener(local6);

    getRootPane().setDefaultButton(localJButton4);

    add(localJPanel);

    pack();
    setLocationRelativeTo(null);
    setVisible(true);
  }

  public void goForIt(Main paramMain, MainApplet paramMainApplet, String paramString)
  {
    try
    {
      String str = paramString.trim();

      if (str.isEmpty()) {
        str = "http://www.minecraft.net/play.jsp";
      }
      this.currentUrl = str;
      parseParameters(paramMainApplet, getPage(str, paramMain.getLoginCookie()));

      setVisible(false);
    }
    catch (IOException localIOException)
    {
      JOptionPane.showMessageDialog(this, "Could not parse the necessary parameters. Is the URL right?");
    }
  }

  private String getPage(String paramString1, String paramString2) throws IOException
  {
    StringBuilder localStringBuilder = new StringBuilder();
    URLConnection localURLConnection = new URL(paramString1).openConnection();

    localURLConnection.addRequestProperty("Cookie", new StringBuilder().append("_lgn=").append(paramString2).toString());
    localURLConnection.setDoInput(true);
    localURLConnection.connect();

    BufferedReader localBufferedReader = new BufferedReader(new InputStreamReader(localURLConnection.getInputStream()));
    char[] arrayOfChar = new char[4096];

    while ((i = localBufferedReader.read(arrayOfChar)) != -1)
    {
      int i;
      localStringBuilder.append(arrayOfChar, 0, i);
    }
    localBufferedReader.close();

    return localStringBuilder.toString();
  }

  private String decodeServerName(String paramString)
  {
    String str = paramString;

    str = str.replaceAll("&lt;", "<");
    str = str.replaceAll("&gt;", ">");

    return str;
  }

  private Map<String, String> parseMaps(String paramString)
  {
    TreeMap localTreeMap = new TreeMap();
    int i = paramString.indexOf("<a href=\"");

    while (i != -1)
    {
      i = paramString.indexOf("play.jsp?user=", i);

      if (i == -1) {
        break;
      }
      String str2 = paramString.substring(i, paramString.indexOf("\"", i));
      i = paramString.indexOf(">", i) + ">".length();
      String str1 = paramString.substring(i, paramString.indexOf("</a>", i));

      localTreeMap.put(decodeServerName(str1), new StringBuilder().append("http://www.minecraft.net/").append(str2).toString());
    }

    return localTreeMap;
  }

  private Map<String, String> parseServers(String paramString)
  {
    TreeMap localTreeMap = new TreeMap();
    int i = paramString.indexOf("<a href=\"");

    while (i != -1)
    {
      i = paramString.indexOf("play.jsp?server=", i);

      if (i == -1) {
        break;
      }
      String str2 = paramString.substring(i, paramString.indexOf("\"", i));
      i = paramString.indexOf("<b>", i) + "<b>".length();
      String str1 = paramString.substring(i, paramString.indexOf("</b>", i));
      i = paramString.indexOf("</a>", i) + "</a>".length();
      str1 = new StringBuilder().append(str1).append(paramString.substring(i, paramString.indexOf(10, i))).toString();

      localTreeMap.put(decodeServerName(str1), new StringBuilder().append("http://www.minecraft.net/").append(str2).toString());
    }

    return localTreeMap;
  }

  private void parseParameters(MainApplet paramMainApplet, String paramString)
  {
    for (String str1 : PARAMETERS)
    {
      int k = paramString.indexOf(new StringBuilder().append("name=\"").append(str1).append("\"").toString());

      if (k == -1)
        continue;
      k = paramString.indexOf("value=\"", k) + "value=\"".length();

      String str2 = paramString.substring(k, paramString.indexOf("\"", k));

      System.out.println(new StringBuilder().append(str1).append(": ").append(str2).toString());

      paramMainApplet.putParameter(str1, str2);
    }
  }

  private static class BookmarkListModel extends AbstractListModel
  {
    private List<String> bookmarks;

    BookmarkListModel(Map<String, String> paramMap)
    {
      this.bookmarks = new ArrayList(paramMap.keySet());
    }

    public Object getElementAt(int paramInt)
    {
      return this.bookmarks.get(paramInt);
    }

    public int getSize()
    {
      return this.bookmarks.size();
    }

    public void add(String paramString)
    {
      this.bookmarks.add(paramString);
      Collections.sort(this.bookmarks);
      fireContentsChanged(this, 0, getSize());
    }

    public void remove(int paramInt)
    {
      this.bookmarks.remove(paramInt);
      fireContentsChanged(this, 0, getSize());
    }
  }
}


Is This A Good Question/Topic? 0
  • +

Replies To: Help with Java.

#2 SwiftStriker00  Icon User is offline

  • Microsoft Insider
  • member icon

Reputation: 432
  • View blog
  • Posts: 1,596
  • Joined: 25-December 08

Re: Help with Java.

Posted 08 February 2010 - 03:15 PM

the compiler is telling you your errors: ';' expected, means you forgot to put ; at the end of your statement.

and this: "ServerDialog.6 local6 =" is not a statement, are you trying to say "ServerDialog.local6 = ..." or "ServerDialog.6 = ....", or are you trying to do
"local6 = ....;
ServerDialog.6 = local6;"
Was This Post Helpful? 0
  • +
  • -

#3 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10180
  • View blog
  • Posts: 37,586
  • Joined: 27-December 08

Re: Help with Java.

Posted 08 February 2010 - 03:17 PM

For this statement (ServerDialog.5), it implies that you have a variable named 5 (which is illegal naming conventions) in your ServerDialog class. In addition, why are you declaring it as a new Object? Why don't you just declare it as a new ServerDialog? Also, you are missing a semi-colon at the end.
ServerDialog.5 local5 = new Object(localJTextField, localHashMap, localJList1, localJList2, localJList3)


For this statement, the only difference from what I said above is that you try to instantiate this Object as a MouseAdapter. However, ServerDialog extends JDialog, not MouseAdapter so this is illegal. Also, neither Object nor MouseAdapter have these constructors. If you want to use ServerDialog constructors, declare your objects as new ServerDialogs().
ServerDialog.6 local6 = new MouseAdapter(paramMain, paramMainApplet, localJTextField)

Was This Post Helpful? 0
  • +
  • -

#4 BlakeRey  Icon User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • Posts: 23
  • Joined: 08-February 10

Re: Help with Java.

Posted 08 February 2010 - 03:48 PM

Right, I have fixed everything, but then this appears.
When I add the ';' it gives me 100 errors, what would that be?

ServerDialog.java:245: ';' expected
    }
     ^
1 error



Here is my ServerDialog.java now.

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import javax.swing.AbstractListModel;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRootPane;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
 
public class ServerDialog extends JDialog
{
  private static final String[] PARAMETERS = { "username", "sessionid", "loadmap_user", "loadmap_id", "server", "port", "mppass", "haspaid" };
  public String currentUrl;
 
  public ServerDialog(Main paramMain, MainApplet paramMainApplet, String paramString)
  {
    goForIt(paramMain, paramMainApplet, paramString);
  }
 
  public ServerDialog(Main paramMain, MainApplet paramMainApplet) {
    super(paramMain, "Select a Server", true);
    Map localMap1;
    Map localMap2;
    Map localMap3;
    try
    {
      localMap1 = parseMaps(getPage("http://www.minecraft.net/", paramMain.getLoginCookie()));
      localMap2 = parseServers(getPage("http://www.minecraft.net/servers.jsp", paramMain.getLoginCookie()));
      localMap3 = Main.getBookmarks();
    }
    catch (IOException localIOException)
    {
      JOptionPane.showMessageDialog(this, "Could not retrieve server list. Going single-player.");
 
      return;
    }
 
    HashMap localHashMap = new HashMap();
 
    localHashMap.put("maps", localMap1);
    localHashMap.put("servers", localMap2);
    localHashMap.put("bookmarks", localMap3);
 
    JPanel localJPanel = new JPanel();
 
    localJPanel.setLayout(new BoxLayout(localJPanel, 1));
    localJPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
 
    JTextField localJTextField = new JTextField(50);
 
    Box localBox = Box.createHorizontalBox();
    localBox.add(new JLabel("Your Maps:"));
    localBox.add(Box.createHorizontalGlue());
    localJPanel.add(localBox);
 
    localJPanel.add(Box.createVerticalStrut(5));
    JList localJList1;
    localJPanel.add(new JScrollPane(localJList1 = new JList(localMap1.keySet().toArray())));
    localJList1.setName("maps");
    localJList1.setSelectionMode(0);
 
    localJPanel.add(Box.createVerticalStrut(5));
 
    localBox = Box.createHorizontalBox();
    localBox.add(new JLabel("Servers:"));
    localBox.add(Box.createHorizontalGlue());
    localJPanel.add(localBox);
 
    localJPanel.add(Box.createVerticalStrut(5));
    JList localJList2;
    localJPanel.add(new JScrollPane(localJList2 = new JList(localMap2.keySet().toArray())));
    localJList2.setName("servers");
    localJList2.setSelectionMode(0);
 
    localJPanel.add(Box.createVerticalStrut(5));
 
    localBox = Box.createHorizontalBox();
    localBox.add(new JLabel("Bookmarks:"));
    localBox.add(Box.createHorizontalGlue());
    JButton localJButton1;
    localBox.add(localJButton1 = new JButton("Add"));
    localBox.add(Box.createHorizontalStrut(5));
    JButton localJButton2;
    localBox.add(localJButton2 = new JButton("Edit"));
    localBox.add(Box.createHorizontalStrut(5));
    JButton localJButton3;
    localBox.add(localJButton3 = new JButton("Delete"));
    localJPanel.add(localBox);
 
    localJPanel.add(Box.createVerticalStrut(5));
    ServerDialog.BookmarkListModel localBookmarkListModel;
    JList localJList3;
    localJPanel.add(new JScrollPane(localJList3 = new JList(localBookmarkListModel = new ServerDialog.BookmarkListModel(localMap3))));
    localJList3.setName("bookmarks");
    localJList3.setSelectionMode(0);
 
    localJPanel.add(Box.createVerticalStrut(5));
 
    localBox = Box.createHorizontalBox();
    localBox.add(new JLabel("<html>Choose a server above or paste a <code>play.jsp</code> URL below. Leave blank to generate a level.</html>"));
    localBox.add(Box.createHorizontalGlue());
    localJPanel.add(localBox);
 
    localJPanel.add(Box.createVerticalStrut(5));
 
    localBox = Box.createHorizontalBox();
    localBox.add(new JLabel("URL:"));
    localBox.add(Box.createHorizontalStrut(5));
    localBox.add(localJTextField);
    localJPanel.add(localBox);
 
    localJPanel.add(Box.createVerticalStrut(5));
 
    localBox = Box.createHorizontalBox();
    localBox.add(Box.createHorizontalGlue());
    JButton localJButton4;
    localBox.add(localJButton4 = new JButton("Go!"));
    localBox.add(Box.createHorizontalGlue());
    localJPanel.add(localBox);
 
    localJButton1.addActionListener(new ActionListener(localJButton1, localMap3, localBookmarkListModel, localJList3)
    {
      public void actionPerformed(ActionEvent paramActionEvent)
      {
        String str1;
        do
        {
          str1 = JOptionPane.showInputDialog(this.val$addButton, "Enter a name for the bookmark:");
 
          if ((str1 != null) && (this.val$bookmarks.containsKey(str1)))
            JOptionPane.showMessageDialog(this.val$addButton, "That name is already in use. Please choose another.");
        }
        while ((str1 != null) && (!(str1.isEmpty())) && (this.val$bookmarks.containsKey(str1)));
 
        if ((str1 == null) || (str1.isEmpty())) {
          return;
        }
        String str2;
        do
          str2 = JOptionPane.showInputDialog(this.val$addButton, "Enter the URL for the bookmark:");
        while ((str2 != null) && (str2.isEmpty()));
 
        if (str2 == null) {
          return;
        }
        this.val$bookmarks.put(str1, str2);
        this.val$bookmarkListModel.add(str1);
        this.val$bookmarkList.clearSelection();
        Main.saveBookmark(str1, str2);
      }
    });
    localJButton2.addActionListener(new ActionListener(localJList3, localBookmarkListModel, localMap3, localJButton1)
    {
      public void actionPerformed(ActionEvent paramActionEvent)
      {
        int i = this.val$bookmarkList.getSelectedIndex();
 
        if ((i < 0) || (i >= this.val$bookmarkListModel.getSize())) {
          return;
        }
        String str1 = (String)this.val$bookmarkListModel.getElementAt(i);
        String str2 = (String)this.val$bookmarks.get(str1);
        do
        {
          str2 = JOptionPane.showInputDialog(this.val$addButton, "Enter the URL for the bookmark:", str2); }
        while ((str2 != null) && (str2.isEmpty()));
 
        if (str2 == null) {
          return;
        }
        this.val$bookmarks.put(str1, str2);
        this.val$bookmarkList.clearSelection();
        Main.saveBookmark(str1, str2);
      }
    });
    localJButton3.addActionListener(new ActionListener(localJList3, localBookmarkListModel, localMap3)
    {
      public void actionPerformed(ActionEvent paramActionEvent)
      {
        int i = this.val$bookmarkList.getSelectedIndex();
 
        if ((i < 0) || (i >= this.val$bookmarkListModel.getSize())) {
          return;
        }
        String str = (String)this.val$bookmarkListModel.getElementAt(i);
 
        this.val$bookmarks.remove(str);
        this.val$bookmarkListModel.remove(i);
        this.val$bookmarkList.clearSelection();
        Main.saveBookmark(str, null);
      }
    });
    localJButton4.addActionListener(new ActionListener(paramMain, paramMainApplet, localJTextField)
    {
      public void actionPerformed(ActionEvent paramActionEvent) {
        ServerDialog.this.goForIt(this.val$main, this.val$applet, this.val$textField.getText());
      }
 
    });
    local5 = new Object(localJTextField, localHashMap, localJList1, localJList2, localJList3)
    {
      public void valueChanged(ListSelectionEvent paramListSelectionEvent)
      {
        JList localJList = (JList)paramListSelectionEvent.getSource();
        Object localObject = localJList.getSelectedValue();
 
        if (localObject == null) {
          return;
        }
        this.val$textField.setText((String)((Map)this.val$lists.get(localJList.getName())).get(localObject));
 
        if (!(localJList.equals(this.val$mapList)))
          this.val$mapList.clearSelection();
        if (!(localJList.equals(this.val$serverList)))
          this.val$serverList.clearSelection();
        if (!(localJList.equals(this.val$bookmarkList))) {
          this.val$bookmarkList.clearSelection();
        }
      }
      
    }
    local6 = new MouseAdapter(paramMain, paramMainApplet, localJTextField)
    {
      public void mouseClicked(MouseEvent paramMouseEvent)
      {
        if (paramMouseEvent.getClickCount() == 2)
          ServerDialog.this.goForIt(this.val$main, this.val$applet, this.val$textField.getText());
      }
    };
    localJList1.addListSelectionListener(local5);
    localJList1.addMouseListener(local6);
 
    localJList2.addListSelectionListener(local5);
    localJList2.addMouseListener(local6);
 
    localJList3.addListSelectionListener(local5);
    localJList3.addMouseListener(local6);
 
    getRootPane().setDefaultButton(localJButton4);
 
    add(localJPanel);
 
    pack();
    setLocationRelativeTo(null);
    setVisible(true);
  }
 
  public void goForIt(Main paramMain, MainApplet paramMainApplet, String paramString)
  {
    try
    {
      String str = paramString.trim();
 
      if (str.isEmpty()) {
        str = "http://www.minecraft.net/play.jsp";
      }
      this.currentUrl = str;
      parseParameters(paramMainApplet, getPage(str, paramMain.getLoginCookie()));
 
      setVisible(false);
    }
    catch (IOException localIOException)
    {
      JOptionPane.showMessageDialog(this, "Could not parse the necessary parameters. Is the URL right?");
    }
  }
 
  private String getPage(String paramString1, String paramString2) throws IOException
  {
    StringBuilder localStringBuilder = new StringBuilder();
    URLConnection localURLConnection = new URL(paramString1).openConnection();
 
    localURLConnection.addRequestProperty("Cookie", new StringBuilder().append("_lgn=").append(paramString2).toString());
    localURLConnection.setDoInput(true);
    localURLConnection.connect();
 
    BufferedReader localBufferedReader = new BufferedReader(new InputStreamReader(localURLConnection.getInputStream()));
    char[] arrayOfChar = new char[4096];
 
    while ((i = localBufferedReader.read(arrayOfChar)) != -1)
    {
      int i;
      localStringBuilder.append(arrayOfChar, 0, i);
    }
    localBufferedReader.close();
 
    return localStringBuilder.toString();
  }
 
  private String decodeServerName(String paramString)
  {
    String str = paramString;
 
    str = str.replaceAll("&lt;", "<");
    str = str.replaceAll("&gt;", ">");
 
    return str;
  }
 
  private Map<String, String> parseMaps(String paramString)
  {
    TreeMap localTreeMap = new TreeMap();
    int i = paramString.indexOf("<a href=\"");
 
    while (i != -1)
    {
      i = paramString.indexOf("play.jsp?user=", i);
 
      if (i == -1) {
        break;
      }
      String str2 = paramString.substring(i, paramString.indexOf("\"", i));
      i = paramString.indexOf(">", i) + ">".length();
      String str1 = paramString.substring(i, paramString.indexOf("</a>", i));
 
      localTreeMap.put(decodeServerName(str1), new StringBuilder().append("http://www.minecraft.net/").append(str2).toString());
    }
 
    return localTreeMap;
  }
 
  private Map<String, String> parseServers(String paramString)
  {
    TreeMap localTreeMap = new TreeMap();
    int i = paramString.indexOf("<a href=\"");
 
    while (i != -1)
    {
      i = paramString.indexOf("play.jsp?server=", i);
 
      if (i == -1) {
        break;
      }
      String str2 = paramString.substring(i, paramString.indexOf("\"", i));
      i = paramString.indexOf("<b>", i) + "<b>".length();
      String str1 = paramString.substring(i, paramString.indexOf("</b>", i));
      i = paramString.indexOf("</a>", i) + "</a>".length();
      str1 = new StringBuilder().append(str1).append(paramString.substring(i, paramString.indexOf(10, i))).toString();
 
      localTreeMap.put(decodeServerName(str1), new StringBuilder().append("http://www.minecraft.net/").append(str2).toString());
    }
 
    return localTreeMap;
  }
 
  private void parseParameters(MainApplet paramMainApplet, String paramString)
  {
    for (String str1 : PARAMETERS)
    {
      int k = paramString.indexOf(new StringBuilder().append("name=\"").append(str1).append("\"").toString());
 
      if (k == -1)
        continue;
      k = paramString.indexOf("value=\"", k) + "value=\"".length();
 
      String str2 = paramString.substring(k, paramString.indexOf("\"", k));
 
      System.out.println(new StringBuilder().append(str1).append(": ").append(str2).toString());
 
      paramMainApplet.putParameter(str1, str2);
    }
  }
 
  private static class BookmarkListModel extends AbstractListModel
  {
    private List<String> bookmarks;
 
    BookmarkListModel(Map<String, String> paramMap)
    {
      this.bookmarks = new ArrayList(paramMap.keySet());
    }
 
    public Object getElementAt(int paramInt)
    {
      return this.bookmarks.get(paramInt);
    }
 
    public int getSize()
    {
      return this.bookmarks.size();
    }
 
    public void add(String paramString)
    {
      this.bookmarks.add(paramString);
      Collections.sort(this.bookmarks);
      fireContentsChanged(this, 0, getSize());
    }
 
    public void remove(int paramInt)
    {
      this.bookmarks.remove(paramInt);
      fireContentsChanged(this, 0, getSize());
    }
  }
}

Was This Post Helpful? 0
  • +
  • -

#5 BlakeRey  Icon User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • Posts: 23
  • Joined: 08-February 10

Re: Help with Java.

Posted 08 February 2010 - 04:48 PM

Can anybody help me?.
Was This Post Helpful? 0
  • +
  • -

#6 BlakeRey  Icon User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • Posts: 23
  • Joined: 08-February 10

Re: Help with Java.

Posted 09 February 2010 - 07:36 AM

Please? help?
Was This Post Helpful? 0
  • +
  • -

#7 mentallybroken  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 6
  • View blog
  • Posts: 82
  • Joined: 03-October 07

Re: Help with Java.

Posted 09 February 2010 - 08:51 AM

hey i am wondering . why just use for example import.java.util.*,import javax.swing.* ,import java.awt.* etc i doubt it will make the code bloated . not sure though

This post has been edited by mentallybroken: 09 February 2010 - 08:52 AM

Was This Post Helpful? 0
  • +
  • -

#8 BlakeRey  Icon User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • Posts: 23
  • Joined: 08-February 10

Re: Help with Java.

Posted 09 February 2010 - 04:31 PM

Im still very stuck with the same problem.

Please someone help me.
Was This Post Helpful? 0
  • +
  • -

#9 erik.price  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 485
  • View blog
  • Posts: 2,690
  • Joined: 18-December 08

Re: Help with Java.

Posted 09 February 2010 - 04:36 PM

Did you fix the errors that were caused by missing semicolons? If so, tell us what's not working now
Was This Post Helpful? 0
  • +
  • -

#10 BlakeRey  Icon User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • Posts: 23
  • Joined: 08-February 10

Re: Help with Java.

Posted 09 February 2010 - 04:42 PM

When I add the semi colon's, it gives me 100 errors, I pressume this is a bracket error but can not locate it anywhere.

Main.java
import com.mojang.minecraft.l;
import com.mojang.minecraft.level.Level;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.color.ColorSpace;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.awt.image.ComponentColorModel;
import java.awt.image.DataBufferByte;
import java.awt.image.Raster;
import java.awt.image.WritableRaster;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
import java.io.PrintStream;
import java.lang.management.ManagementFactory;
import java.lang.management.ThreadInfo;
import java.lang.management.ThreadMXBean;
import java.nio.ByteBuffer;
import java.util.Calendar;
import java.util.Map;
import java.util.TreeMap;
import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;
import java.util.zip.GZIPOutputStream;
import javax.imageio.ImageIO;
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.GL11;

public class Main extends JFrame
{
  private static final String TITLE = "Minecraft";
  private static final Preferences PREFERENCES = Preferences.userRoot().node("minecraft");
  private static final Preferences BOOKMARKS = PREFERENCES.node("bookmarks");
  private static final String KEY_LOGIN = "login";
  private static final String KEY_MAXIMIZED = "maximized";
  private static final String KEY_WIDTH = "width";
  private static final String KEY_HEIGHT = "height";
  private static final String KEY_RESTART = "restart";
  private static final String KEY_DETAIL = "detail";
  private static final String KEY_AUTH = "auth";
  private static final int DEFAULT_WIDTH = 854;
  private static final int DEFAULT_HEIGHT = 480;
  private String loginCookie;
  private String myUsername;
  public static MainApplet applet;
  public static boolean hacksEnabled = true;
  public static String inputValue = "";
  private static ServerDialog server;
  private static Box box;
  private static Box panel;
  public static final Main main = new Main();

  public Main()
  {
    this.loginCookie = "";
    this.myUsername = "";
  }

  public static void main(String[] paramArrayOfString)
  {
    String str1 = PREFERENCES.get("restart", null);
    String str2 = PREFERENCES.get("detail", null);
    String str3 = PREFERENCES.get("auth", null);

    PREFERENCES.remove("restart");
    PREFERENCES.remove("detail");
    PREFERENCES.remove("auth");

    if ((str1 != null) && (str1.compareTo("reload") == 0))
    {
      main.loginCookie = str3;
      localObject = str3.split("\\|");
      main.myUsername = localObject[0];

      applet = new MainApplet(main);
      server = new ServerDialog(main, applet, str2);
    }
    else if ((str1 != null) && (str1.compareTo("change") == 0))
    {
      main.loginCookie = str3;
      localObject = str3.split("\\|");
      main.myUsername = localObject[0];

      applet = new MainApplet(main);
      server = new ServerDialog(main, applet);
    }
    else
    {
      new UpdateDialog(main);
      new LoginDialog(main);

      applet = new MainApplet(main);
      server = new ServerDialog(main, applet);
    }

    main.setTitle("Minecraft");

    box = Box.createHorizontalBox();

    Object localObject = new JButton("Switch");
    box.add((Component)localObject);

    JButton localJButton1 = new JButton("Reload");
    box.add(localJButton1);

    JButton localJButton2 = new JButton("Screenshot");
    box.add(localJButton2);

    JButton localJButton3 = new JButton("Dump Level");
    box.add(localJButton3);

    JCheckBox localJCheckBox = new JCheckBox("Enable hacks");
    localJCheckBox.setSelected(hacksEnabled);
    box.add(localJCheckBox);

    box.add(Box.createHorizontalGlue());

    panel = Box.createVerticalBox();

    panel.add(box);
    panel.add(applet);

    main.getContentPane().add(panel);
    main.getContentPane().setPreferredSize(getInitialSize());
    main.pack();
    main.setLocationRelativeTo(null);
    if (isInitiallyMaximized())
      main.setExtendedState(6);
    main.setDefaultCloseOperation(3);
    main.setVisible(true);

    main.addWindowListener(new WindowAdapter()
    {
      public void windowClosing(WindowEvent paramWindowEvent) {
        super.windowClosing(paramWindowEvent);
        System.out.println("stopping...");
        try {
          Main.applet.stop();
          Main.applet.destroy();
        }
        catch (Exception localException) {
          localException.printStackTrace();
        }
        Main.main.saveSize();
      }
    });
    localJButton3.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent paramActionEvent) {
        Main.dumpLevel();
      }
    });
    localJButton2.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent paramActionEvent) {
        new KMenu(Main.applet.getMinecraft());
      }

    });
    ((JButton)localObject).addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent paramActionEvent) {
        Main.PREFERENCES.put("restart", "change");
        Main.PREFERENCES.put("auth", Main.main.loginCookie);
        System.exit(10);
      }
    });
    localJButton1.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent paramActionEvent) {
        Main.PREFERENCES.put("restart", "reload");
        Main.PREFERENCES.put("detail", Main.server.currentUrl);
        Main.PREFERENCES.put("auth", Main.main.loginCookie);
        System.exit(10);
      }
    });
    localJCheckBox.addItemListener(new ItemListener()
    {
      public void itemStateChanged(ItemEvent paramItemEvent) {
        if (paramItemEvent.getStateChange() == 2)
          Main.hacksEnabled = false;
        else
          Main.hacksEnabled = true;
      }
    });
    main.getContentPane().addComponentListener(new ComponentAdapter()
    {
      public void componentResized(ComponentEvent paramComponentEvent) {
        Main.access$400();
        Main.main.saveSize();
      }
    });
    resizeApp();

    applet.init();
    resizeApp();
  }

  private static void resizeApp() {
    Dimension localDimension1 = main.getContentPane().getSize();
    Dimension localDimension2 = box.getSize();
    Dimension localDimension3 = new Dimension(localDimension1.width, localDimension1.height - localDimension2.height);

    applet.setBounds(0, localDimension2.height, localDimension1.width, localDimension1.height - localDimension2.height);
    applet.resize(localDimension3);
    panel.validate();
  }

  private static void shudownApplet()
  {
    panel.remove(applet);
    try {
      applet.stop();
    }
    catch (Exception localException1) {
      localException1.printStackTrace(); }
    Object localObject1;
    try {
      l locall = applet.getMinecraft();
      localObject1 = locall.d;
      ((Level)localObject1).removeListener$74652038(locall.e);
      ((Level)localObject1).rendererContext$5cd64a7f = null;
      ((Level)localObject1).blocks = null;
    }
    catch (Exception localException2) {
      localException2.printStackTrace();
    }
    try {
      Compass.oldCompass.cancel();
      Compass.oldCompass = null;
    }
    catch (Exception localException3) {
      localException3.printStackTrace();
    }
    try {
      Display.destroy();
    }
    catch (Exception localException4) {
      localException4.printStackTrace();
    }
    try {
      applet.minecraft = null;
      applet.destroy();
    }
    catch (Exception localException5) {
      localException5.printStackTrace();
    }
    applet = null;

    System.runFinalization();
    System.gc();

    ThreadMXBean localThreadMXBean = ManagementFactory.getThreadMXBean();

    for (Object localObject2 : localThreadMXBean.dumpAllThreads(true, true))
      System.out.print(localObject2.toString());
  }

  private static boolean isInitiallyMaximized()
  {
    return (PREFERENCES.get("maximized", null) != null);
  }

  private static Dimension getInitialSize()
  {
    String str1 = PREFERENCES.get("width", "");
    String str2 = PREFERENCES.get("height", "");
    try
    {
      return new Dimension(Integer.parseInt(str1), Integer.parseInt(str2));
    }
    catch (NumberFormatException localNumberFormatException) {
    }
    return new Dimension(854, 480);
  }

  private void saveSize()
  {
    if (getExtendedState() == 6)
    {
      PREFERENCES.put("maximized", "yes");
    }
    else
    {
      PREFERENCES.remove("maximized");
      PREFERENCES.put("width", Integer.toString(getContentPane().getWidth()));
      PREFERENCES.put("height", Integer.toString(getContentPane().getHeight()));
    }
  }

  public final String getUsername() {
    return this.myUsername;
  }

  public String getLoginCookie()
  {
    return PREFERENCES.get("login", this.loginCookie);
  }

  public final void setLoginCookie(String paramString1, String paramString2, boolean paramBoolean)
  {
    this.loginCookie = paramString1 + "|" + paramString2;
    this.myUsername = paramString1;

    if (paramBoolean)
      PREFERENCES.put("login", this.loginCookie);
    else
      PREFERENCES.remove("login");
  }

  public static Map<String, String> getBookmarks()
  {
    TreeMap localTreeMap = new TreeMap();
    try
    {
      for (String str : BOOKMARKS.keys())
        localTreeMap.put(str, BOOKMARKS.get(str, ""));
    }
    catch (BackingStoreException localBackingStoreException)
    {
      System.err.println("Error reading bookmarks: " + localBackingStoreException.toString());
    }

    return localTreeMap;
  }

  public static void saveBookmark(String paramString1, String paramString2)
  {
    if (paramString2 == null)
      BOOKMARKS.remove(paramString1);
    else
      BOOKMARKS.put(paramString1, paramString2);
  }

  public void setStatus(String paramString)
  {
    setTitle("Minecraft" + paramString);
  }

  public static byte[] flipPixels(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
  {
    paramInt1 *= 3;
    byte[] arrayOfByte = null;
    if (paramArrayOfByte != null) {
      arrayOfByte = new byte[paramInt1 * paramInt2];
      for (int i = 0; i < paramInt2; ++i) {
        for (int j = 0; j < paramInt1; ++j) {
          arrayOfByte[((paramInt2 - i - 1) * paramInt1 + j)] = paramArrayOfByte[(i * paramInt1 + j)];
        }
      }
    }
    return arrayOfByte;
  }

  public static void dumpScreen(int paramInt1, int paramInt2)
  {
    try {
      System.out.println("Taking screenshot: " + paramInt1 + "x" + paramInt2);
      l locall = applet.getMinecraft();

      int i = 6400;
      int j = paramInt2;
      int k = i * j * 3;

      GL11.glReadBuffer(1028);
      ByteBuffer localByteBuffer = ByteBuffer.allocateDirect(k);
      GL11.glReadPixels(0, 0, i, j, 6407, 5121, localByteBuffer);

      byte[] arrayOfByte = new byte[k];
      localByteBuffer.get(arrayOfByte);
      arrayOfByte = flipPixels(arrayOfByte, i, paramInt2);

      ColorSpace localColorSpace = ColorSpace.getInstance(1000);
      int[] arrayOfInt1 = { 8, 8, 8 };
      int[] arrayOfInt2 = { 0, 1, 2 };

      ComponentColorModel localComponentColorModel = new ComponentColorModel(localColorSpace, arrayOfInt1, false, false, 3, 0);

      WritableRaster localWritableRaster = Raster.createInterleavedRaster(new DataBufferByte(arrayOfByte, arrayOfByte.length), paramInt1, paramInt2, i * 3, 3, arrayOfInt2, null);

      BufferedImage localBufferedImage = new BufferedImage(localComponentColorModel, localWritableRaster, false, null);

      String str = String.format("screenshot_%1$tY%1$tm%1$td%1$tH%1$tM%1$tS.png", new Object[] { Calendar.getInstance() });
      ImageIO.write(localBufferedImage, "png", new File(str));
    }
    catch (Exception localException) {
      localException.printStackTrace();
    }
  }

  public static void dumpLevel() {
    FileOutputStream localFileOutputStream = null;
    GZIPOutputStream localGZIPOutputStream = null;
    ObjectOutputStream localObjectOutputStream = null;
    DataOutputStream localDataOutputStream = null;
    try {
      String str = String.format("level_%1$tY%1$tm%1$td%1$tH%1$tM%1$tS.dat", new Object[] { Calendar.getInstance() });
      localFileOutputStream = new FileOutputStream(str);
      localGZIPOutputStream = new GZIPOutputStream(localFileOutputStream);
      localDataOutputStream = new DataOutputStream(localGZIPOutputStream);
      localDataOutputStream.writeInt(656127880);
      localDataOutputStream.writeByte(2);
      localObjectOutputStream = new ObjectOutputStream(localGZIPOutputStream);
      if (applet == null) {
        System.out.println("No applet object!");
      } else {
        l locall = applet.getMinecraft();
        if (locall == null) {
          System.out.println("No minecraft object!");
        } else if (locall.d == null) {
          System.out.println("No minecraft level object!");
        } else {
          Level localLevel1 = new Level();
          Level localLevel2 = locall.d;

          localLevel1.blocks = localLevel2.copyBlocks();
          localLevel1.width = localLevel2.width;
          localLevel1.height = localLevel2.height;
          localLevel1.depth = localLevel2.depth;
          localLevel1.name = localLevel2.name;
          localLevel1.creator = localLevel2.creator;
          localLevel1.createTime = localLevel2.createTime;
          localLevel1.xSpawn = localLevel2.xSpawn;
          localLevel1.ySpawn = localLevel2.ySpawn;
          localLevel1.zSpawn = localLevel2.zSpawn;
          localLevel1.rotSpawn = localLevel2.rotSpawn;
          localObjectOutputStream.writeObject(localLevel1);
          localDataOutputStream.close();
          localObjectOutputStream.close();
        }
      }
    } catch (Exception localException) {
      localException.printStackTrace();
    }
  }
}


ServerDialog.java
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import javax.swing.AbstractListModel;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRootPane;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
 
public class ServerDialog extends JDialog
{
  private static final String[] PARAMETERS = { "username", "sessionid", "loadmap_user", "loadmap_id", "server", "port", "mppass", "haspaid" };
  public String currentUrl;
 
  public ServerDialog(Main paramMain, MainApplet paramMainApplet, String paramString)
  {
    goForIt(paramMain, paramMainApplet, paramString);
  }
 
  public ServerDialog(Main paramMain, MainApplet paramMainApplet) {
    super(paramMain, "Select a Server", true);
    Map localMap1;
    Map localMap2;
    Map localMap3;
    try
    {
      localMap1 = parseMaps(getPage("http://www.minecraft.net/", paramMain.getLoginCookie()));
      localMap2 = parseServers(getPage("http://www.minecraft.net/servers.jsp", paramMain.getLoginCookie()));
      localMap3 = Main.getBookmarks();
    }
    catch (IOException localIOException)
    {
      JOptionPane.showMessageDialog(this, "Could not retrieve server list. Going single-player.");
 
      return;
    }
 
    HashMap localHashMap = new HashMap();
 
    localHashMap.put("maps", localMap1);
    localHashMap.put("servers", localMap2);
    localHashMap.put("bookmarks", localMap3);
 
    JPanel localJPanel = new JPanel();
 
    localJPanel.setLayout(new BoxLayout(localJPanel, 1));
    localJPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
 
    JTextField localJTextField = new JTextField(50);
 
    Box localBox = Box.createHorizontalBox();
    localBox.add(new JLabel("Your Maps:"));
    localBox.add(Box.createHorizontalGlue());
    localJPanel.add(localBox);
 
    localJPanel.add(Box.createVerticalStrut(5));
    JList localJList1;
    localJPanel.add(new JScrollPane(localJList1 = new JList(localMap1.keySet().toArray())));
    localJList1.setName("maps");
    localJList1.setSelectionMode(0);
 
    localJPanel.add(Box.createVerticalStrut(5));
 
    localBox = Box.createHorizontalBox();
    localBox.add(new JLabel("Servers:"));
    localBox.add(Box.createHorizontalGlue());
    localJPanel.add(localBox);
 
    localJPanel.add(Box.createVerticalStrut(5));
    JList localJList2;
    localJPanel.add(new JScrollPane(localJList2 = new JList(localMap2.keySet().toArray())));
    localJList2.setName("servers");
    localJList2.setSelectionMode(0);
 
    localJPanel.add(Box.createVerticalStrut(5));
 
    localBox = Box.createHorizontalBox();
    localBox.add(new JLabel("Bookmarks:"));
    localBox.add(Box.createHorizontalGlue());
    JButton localJButton1;
    localBox.add(localJButton1 = new JButton("Add"));
    localBox.add(Box.createHorizontalStrut(5));
    JButton localJButton2;
    localBox.add(localJButton2 = new JButton("Edit"));
    localBox.add(Box.createHorizontalStrut(5));
    JButton localJButton3;
    localBox.add(localJButton3 = new JButton("Delete"));
    localJPanel.add(localBox);
 
    localJPanel.add(Box.createVerticalStrut(5));
    ServerDialog.BookmarkListModel localBookmarkListModel;
    JList localJList3;
    localJPanel.add(new JScrollPane(localJList3 = new JList(localBookmarkListModel = new ServerDialog.BookmarkListModel(localMap3))));
    localJList3.setName("bookmarks");
    localJList3.setSelectionMode(0);
 
    localJPanel.add(Box.createVerticalStrut(5));
 
    localBox = Box.createHorizontalBox();
    localBox.add(new JLabel("<html>Choose a server above or paste a <code>play.jsp</code> URL below. Leave blank to generate a level.</html>"));
    localBox.add(Box.createHorizontalGlue());
    localJPanel.add(localBox);
 
    localJPanel.add(Box.createVerticalStrut(5));
 
    localBox = Box.createHorizontalBox();
    localBox.add(new JLabel("URL:"));
    localBox.add(Box.createHorizontalStrut(5));
    localBox.add(localJTextField);
    localJPanel.add(localBox);
 
    localJPanel.add(Box.createVerticalStrut(5));
 
    localBox = Box.createHorizontalBox();
    localBox.add(Box.createHorizontalGlue());
    JButton localJButton4;
    localBox.add(localJButton4 = new JButton("Go!"));
    localBox.add(Box.createHorizontalGlue());
    localJPanel.add(localBox);
 
    localJButton1.addActionListener(new ActionListener(localJButton1, localMap3, localBookmarkListModel, localJList3)
    {
      public void actionPerformed(ActionEvent paramActionEvent)
      {
        String str1;
        do
        {
          str1 = JOptionPane.showInputDialog(this.val$addButton, "Enter a name for the bookmark:");
 
          if ((str1 != null) && (this.val$bookmarks.containsKey(str1)))
            JOptionPane.showMessageDialog(this.val$addButton, "That name is already in use. Please choose another.");
        }
        while ((str1 != null) && (!(str1.isEmpty())) && (this.val$bookmarks.containsKey(str1)));
 
        if ((str1 == null) || (str1.isEmpty())) {
          return;
        }
        String str2;
        do
          str2 = JOptionPane.showInputDialog(this.val$addButton, "Enter the URL for the bookmark:");
        while ((str2 != null) && (str2.isEmpty()));
 
        if (str2 == null) {
          return;
        }
        this.val$bookmarks.put(str1, str2);
        this.val$bookmarkListModel.add(str1);
        this.val$bookmarkList.clearSelection();
        Main.saveBookmark(str1, str2);
      }
    });
    localJButton2.addActionListener(new ActionListener(localJList3, localBookmarkListModel, localMap3, localJButton1)
    {
      public void actionPerformed(ActionEvent paramActionEvent)
      {
        int i = this.val$bookmarkList.getSelectedIndex();
 
        if ((i < 0) || (i >= this.val$bookmarkListModel.getSize())) {
          return;
        }
        String str1 = (String)this.val$bookmarkListModel.getElementAt(i);
        String str2 = (String)this.val$bookmarks.get(str1);
        do
        {
          str2 = JOptionPane.showInputDialog(this.val$addButton, "Enter the URL for the bookmark:", str2); }
        while ((str2 != null) && (str2.isEmpty()));
 
        if (str2 == null) {
          return;
        }
        this.val$bookmarks.put(str1, str2);
        this.val$bookmarkList.clearSelection();
        Main.saveBookmark(str1, str2);
      }
    });
    localJButton3.addActionListener(new ActionListener(localJList3, localBookmarkListModel, localMap3)
    {
      public void actionPerformed(ActionEvent paramActionEvent)
      {
        int i = this.val$bookmarkList.getSelectedIndex();
 
        if ((i < 0) || (i >= this.val$bookmarkListModel.getSize())) {
          return;
        }
        String str = (String)this.val$bookmarkListModel.getElementAt(i);
 
        this.val$bookmarks.remove(str);
        this.val$bookmarkListModel.remove(i);
        this.val$bookmarkList.clearSelection();
        Main.saveBookmark(str, null);
      }
    });
    localJButton4.addActionListener(new ActionListener(paramMain, paramMainApplet, localJTextField)
    {
      public void actionPerformed(ActionEvent paramActionEvent) {
        ServerDialog.this.goForIt(this.val$main, this.val$applet, this.val$textField.getText());
      }
 
    });
    local5 = new Object (localJTextField, localHashMap, localJList1, localJList2, localJList3)
    {
      public void valueChanged(ListSelectionEvent paramListSelectionEvent)
      {
        JList localJList = (JList)paramListSelectionEvent.getSource();
        Object localObject = localJList.getSelectedValue();
        
        if (localObject == null) {
          return;
        }
        this.val$textField.setText((String)((Map)this.val$lists.get(localJList.getName())).get(localObject));
 
        if (!(localJList.equals(this.val$mapList)))
          this.val$mapList.clearSelection();
        if (!(localJList.equals(this.val$serverList)))
          this.val$serverList.clearSelection();
        if (!(localJList.equals(this.val$bookmarkList))) {
          this.val$bookmarkList.clearSelection();
        }
      }
      
    };
    local6 = new MouseAdapter(paramMain, paramMainApplet, localJTextField)
    {
      public void mouseClicked(MouseEvent paramMouseEvent)
      {
        if (paramMouseEvent.getClickCount() == 2)
          ServerDialog.this.goForIt(this.val$main, this.val$applet, this.val$textField.getText());
      }
    };
    localJList1.addListSelectionListener(local5);
    localJList1.addMouseListener(local6);
 
    localJList2.addListSelectionListener(local5);
    localJList2.addMouseListener(local6);
 
    localJList3.addListSelectionListener(local5);
    localJList3.addMouseListener(local6);
 
    getRootPane().setDefaultButton(localJButton4);
 
    add(localJPanel);
 
    pack();
    setLocationRelativeTo(null);
    setVisible(true);
  }
 
  public void goForIt(Main paramMain, MainApplet paramMainApplet, String paramString)
  {
    try
    {
      String str = paramString.trim();
 
      if (str.isEmpty()) {
        str = "http://www.minecraft.net/play.jsp";
      }
      this.currentUrl = str;
      parseParameters(paramMainApplet, getPage(str, paramMain.getLoginCookie()));
 
      setVisible(false);
    }
    catch (IOException localIOException)
    {
      JOptionPane.showMessageDialog(this, "Could not parse the necessary parameters. Is the URL right?");
    }
  }
 
  private String getPage(String paramString1, String paramString2) throws IOException
  {
    StringBuilder localStringBuilder = new StringBuilder();
    URLConnection localURLConnection = new URL(paramString1).openConnection();
 
    localURLConnection.addRequestProperty("Cookie", new StringBuilder().append("_lgn=").append(paramString2).toString());
    localURLConnection.setDoInput(true);
    localURLConnection.connect();
 
    BufferedReader localBufferedReader = new BufferedReader(new InputStreamReader(localURLConnection.getInputStream()));
    char[] arrayOfChar = new char[4096];
 
    while ((i = localBufferedReader.read(arrayOfChar)) != -1)
    {
      int i;
      localStringBuilder.append(arrayOfChar, 0, i);
    }
    localBufferedReader.close();
 
    return localStringBuilder.toString();
  }
 
  private String decodeServerName(String paramString)
  {
    String str = paramString;
 
    str = str.replaceAll("&lt;", "<");
    str = str.replaceAll("&gt;", ">");
 
    return str;
  }
 
  private Map<String, String> parseMaps(String paramString)
  {
    TreeMap localTreeMap = new TreeMap();
    int i = paramString.indexOf("<a href=\"");
 
    while (i != -1)
    {
      i = paramString.indexOf("play.jsp?user=", i);
 
      if (i == -1) {
        break;
      }
      String str2 = paramString.substring(i, paramString.indexOf("\"", i));
      i = paramString.indexOf(">", i) + ">".length();
      String str1 = paramString.substring(i, paramString.indexOf("</a>", i));
 
      localTreeMap.put(decodeServerName(str1), new StringBuilder().append("http://www.minecraft.net/").append(str2).toString());
    }
 
    return localTreeMap;
  }
 
  private Map<String, String> parseServers(String paramString)
  {
    TreeMap localTreeMap = new TreeMap();
    int i = paramString.indexOf("<a href=\"");
 
    while (i != -1)
    {
      i = paramString.indexOf("play.jsp?server=", i);
 
      if (i == -1) {
        break;
      }
      String str2 = paramString.substring(i, paramString.indexOf("\"", i));
      i = paramString.indexOf("<b>", i) + "<b>".length();
      String str1 = paramString.substring(i, paramString.indexOf("</b>", i));
      i = paramString.indexOf("</a>", i) + "</a>".length();
      str1 = new StringBuilder().append(str1).append(paramString.substring(i, paramString.indexOf(10, i))).toString();
 
      localTreeMap.put(decodeServerName(str1), new StringBuilder().append("http://www.minecraft.net/").append(str2).toString());
    }
 
    return localTreeMap;
  }
 
  private void parseParameters(MainApplet paramMainApplet, String paramString)
  {
    for (String str1 : PARAMETERS)
    {
      int k = paramString.indexOf(new StringBuilder().append("name=\"").append(str1).append("\"").toString());
 
      if (k == -1)
        continue;
      k = paramString.indexOf("value=\"", k) + "value=\"".length();
 
      String str2 = paramString.substring(k, paramString.indexOf("\"", k));
 
      System.out.println(new StringBuilder().append(str1).append(": ").append(str2).toString());
 
      paramMainApplet.putParameter(str1, str2);
    }
  }
 
  private static class BookmarkListModel extends AbstractListModel
  {
    private List<String> bookmarks;
 
    BookmarkListModel(Map<String, String> paramMap)
    {
      this.bookmarks = new ArrayList(paramMap.keySet());
    }
 
    public Object getElementAt(int paramInt)
    {
      return this.bookmarks.get(paramInt);
    }
 
    public int getSize()
    {
      return this.bookmarks.size();
    }
 
    public void add(String paramString)
    {
      this.bookmarks.add(paramString);
      Collections.sort(this.bookmarks);
      fireContentsChanged(this, 0, getSize());
    }
 
    public void remove(int paramInt)
    {
      this.bookmarks.remove(paramInt);
      fireContentsChanged(this, 0, getSize());
    }
  }
}


Errors:
Main.java:95: cannot find symbol
symbol  : variable localObject
location: class Main
      localObject = str3.split("\\|");
      ^
Main.java:96: cannot find symbol
symbol  : variable localObject
location: class Main
      main.myUsername = localObject[0];
                        ^
Main.java:135: cannot find symbol
symbol  : method add(MainApplet)
location: class javax.swing.Box
    panel.add(applet);
         ^
Main.java:152: cannot find symbol
symbol  : method stop()
location: class MainApplet
          Main.applet.stop();
                     ^
Main.java:153: cannot find symbol
symbol  : method destroy()
location: class MainApplet
          Main.applet.destroy();
                     ^
Main.java:203: cannot find symbol
symbol  : method access$400()
location: class Main
        Main.access$400();
            ^
Main.java:218: cannot find symbol
symbol  : method setBounds(int,int,int,int)
location: class MainApplet
    applet.setBounds(0, localDimension2.height, localDimension1.width, localDime
nsion1.height - localDimension2.height);
          ^
Main.java:227: cannot find symbol
symbol  : method stop()
location: class MainApplet
      applet.stop();
            ^
Main.java:233: cannot find symbol
symbol  : class l
location: class Main
      l locall = applet.getMinecraft();
      ^
Main.java:235: cannot find symbol
symbol  : class Level
location: class Main
      ((Level)localObject1).removeListener$74652038(locall.e);
        ^
Main.java:236: cannot find symbol
symbol  : class Level
location: class Main
      ((Level)localObject1).rendererContext$5cd64a7f = null;
        ^
Main.java:237: cannot find symbol
symbol  : class Level
location: class Main
      ((Level)localObject1).blocks = null;
        ^
Main.java:250: cannot find symbol
symbol  : variable Display
location: class Main
      Display.destroy();
      ^
Main.java:257: cannot find symbol
symbol  : method destroy()
location: class MainApplet
      applet.destroy();
            ^
Main.java:373: cannot find symbol
symbol  : class l
location: class Main
      l locall = applet.getMinecraft();
      ^
Main.java:379: cannot find symbol
symbol  : variable GL11
location: class Main
      GL11.glReadBuffer(1028);
      ^
Main.java:381: cannot find symbol
symbol  : variable GL11
location: class Main
      GL11.glReadPixels(0, 0, i, j, 6407, 5121, localByteBuffer);
      ^
Main.java:418: operator == cannot be applied to MainApplet,<nulltype>
      if (applet == null) {
                 ^
Main.java:421: cannot find symbol
symbol  : class l
location: class Main
        l locall = applet.getMinecraft();
        ^
Main.java:427: cannot find symbol
symbol  : class Level
location: class Main
          Level localLevel1 = new Level();
          ^
Main.java:427: cannot find symbol
symbol  : class Level
location: class Main
          Level localLevel1 = new Level();
                                  ^
Main.java:428: cannot find symbol
symbol  : class Level
location: class Main
          Level localLevel2 = locall.d;
          ^
MainApplet.java:61: cannot find symbol
symbol  : variable super
location: class MainApplet
    super.resize(paramDimension);
    ^
MainApplet.java:77: cannot find symbol
symbol  : class MinecraftApplet
location: class MainApplet
      Field localField = MinecraftApplet.class.getDeclaredField("minecraft");
                         ^
MainApplet.java:81: cannot find symbol
symbol  : class l
location: class MainApplet
      return ((l)localField.get(this));
               ^
MainApplet.java:81: get(java.lang.Object) in java.lang.reflect.Field cannot be a
pplied to (MainApplet)
      return ((l)localField.get(this));
                           ^
MainApplet.java:92: cannot find symbol
symbol  : variable super
location: class MainApplet
    super.init();
    ^
ServerDialog.java:145: anonymous class implements interface; cannot have argumen
ts
    localJButton1.addActionListener(new ActionListener(localJButton1, localMap3,
 localBookmarkListModel, localJList3)
                                                       ^
ServerDialog.java:152: cannot find symbol
symbol: variable val$addButton
          str1 = JOptionPane.showInputDialog(this.val$addButton, "Enter a name f
or the bookmark:");
                                                 ^
ServerDialog.java:154: cannot find symbol
symbol: variable val$bookmarks
          if ((str1 != null) && (this.val$bookmarks.containsKey(str1)))
                                     ^
ServerDialog.java:155: cannot find symbol
symbol: variable val$addButton
            JOptionPane.showMessageDialog(this.val$addButton, "That name is alre
ady in use. Please choose another.");
                                              ^
ServerDialog.java:157: cannot find symbol
symbol: variable val$bookmarks
        while ((str1 != null) && (!(str1.isEmpty())) && (this.val$bookmarks.cont
ainsKey(str1)));
                                                             ^
ServerDialog.java:164: cannot find symbol
symbol: variable val$addButton
          str2 = JOptionPane.showInputDialog(this.val$addButton, "Enter the URL
for the bookmark:");
                                                 ^
ServerDialog.java:170: cannot find symbol
symbol: variable val$bookmarks
        this.val$bookmarks.put(str1, str2);
            ^
ServerDialog.java:171: cannot find symbol
symbol: variable val$bookmarkListModel
        this.val$bookmarkListModel.add(str1);
            ^
ServerDialog.java:172: cannot find symbol
symbol: variable val$bookmarkList
        this.val$bookmarkList.clearSelection();
            ^
ServerDialog.java:176: anonymous class implements interface; cannot have argumen
ts
    localJButton2.addActionListener(new ActionListener(localJList3, localBookmar
kListModel, localMap3, localJButton1)
                                                       ^
ServerDialog.java:180: cannot find symbol
symbol: variable val$bookmarkList
        int i = this.val$bookmarkList.getSelectedIndex();
                    ^
ServerDialog.java:182: cannot find symbol
symbol: variable val$bookmarkListModel
        if ((i < 0) || (i >= this.val$bookmarkListModel.getSize())) {
                                 ^
ServerDialog.java:185: cannot find symbol
symbol: variable val$bookmarkListModel
        String str1 = (String)this.val$bookmarkListModel.getElementAt(i);
                                  ^
ServerDialog.java:186: cannot find symbol
symbol: variable val$bookmarks
        String str2 = (String)this.val$bookmarks.get(str1);
                                  ^
ServerDialog.java:189: cannot find symbol
symbol: variable val$addButton
          str2 = JOptionPane.showInputDialog(this.val$addButton, "Enter the URL
for the bookmark:", str2); }
                                                 ^
ServerDialog.java:195: cannot find symbol
symbol: variable val$bookmarks
        this.val$bookmarks.put(str1, str2);
            ^
ServerDialog.java:196: cannot find symbol
symbol: variable val$bookmarkList
        this.val$bookmarkList.clearSelection();
            ^
ServerDialog.java:200: anonymous class implements interface; cannot have argumen
ts
    localJButton3.addActionListener(new ActionListener(localJList3, localBookmar
kListModel, localMap3)
                                                       ^
ServerDialog.java:204: cannot find symbol
symbol: variable val$bookmarkList
        int i = this.val$bookmarkList.getSelectedIndex();
                    ^
ServerDialog.java:206: cannot find symbol
symbol: variable val$bookmarkListModel
        if ((i < 0) || (i >= this.val$bookmarkListModel.getSize())) {
                                 ^
ServerDialog.java:209: cannot find symbol
symbol: variable val$bookmarkListModel
        String str = (String)this.val$bookmarkListModel.getElementAt(i);
                                 ^
ServerDialog.java:211: cannot find symbol
symbol: variable val$bookmarks
        this.val$bookmarks.remove(str);
            ^
ServerDialog.java:212: cannot find symbol
symbol: variable val$bookmarkListModel
        this.val$bookmarkListModel.remove(i);
            ^
ServerDialog.java:213: cannot find symbol
symbol: variable val$bookmarkList
        this.val$bookmarkList.clearSelection();
            ^
ServerDialog.java:217: anonymous class implements interface; cannot have argumen
ts
    localJButton4.addActionListener(new ActionListener(paramMain, paramMainApple
t, localJTextField)
                                                       ^
ServerDialog.java:220: cannot find symbol
symbol: variable val$main
        ServerDialog.this.goForIt(this.val$main, this.val$applet, this.val$textF
ield.getText());
                                      ^
ServerDialog.java:220: cannot find symbol
symbol: variable val$applet
        ServerDialog.this.goForIt(this.val$main, this.val$applet, this.val$textF
ield.getText());
                                                     ^
ServerDialog.java:220: cannot find symbol
symbol: variable val$textField
        ServerDialog.this.goForIt(this.val$main, this.val$applet, this.val$textF
ield.getText());
                                                                      ^
ServerDialog.java:224: cannot find symbol
symbol  : variable local5
location: class ServerDialog
    local5 = new Object (localJTextField, localHashMap, localJList1, localJList2
, localJList3)
    ^
ServerDialog.java:224: Object() in java.lang.Object cannot be applied to (javax.
swing.JTextField,java.util.HashMap,javax.swing.JList,javax.swing.JList,javax.swi
ng.JList)
    local5 = new Object (localJTextField, localHashMap, localJList1, localJList2
, localJList3)
             ^
ServerDialog.java:234: cannot find symbol
symbol: variable val$lists
        this.val$textField.setText((String)((Map)this.val$lists.get(localJList.g
etName())).get(localObject));
                                                     ^
ServerDialog.java:234: cannot find symbol
symbol: variable val$textField
        this.val$textField.setText((String)((Map)this.val$lists.get(localJList.g
etName())).get(localObject));
            ^
ServerDialog.java:236: cannot find symbol
symbol: variable val$mapList
        if (!(localJList.equals(this.val$mapList)))
                                    ^
ServerDialog.java:237: cannot find symbol
symbol: variable val$mapList
          this.val$mapList.clearSelection();
              ^
ServerDialog.java:238: cannot find symbol
symbol: variable val$serverList
        if (!(localJList.equals(this.val$serverList)))
                                    ^
ServerDialog.java:239: cannot find symbol
symbol: variable val$serverList
          this.val$serverList.clearSelection();
              ^
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
100 errors
Finished!

Was This Post Helpful? 0
  • +
  • -

#11 BlakeRey  Icon User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • Posts: 23
  • Joined: 08-February 10

Re: Help with Java.

Posted 09 February 2010 - 05:43 PM

Anyone? :(
Was This Post Helpful? 0
  • +
  • -

#12 erik.price  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 485
  • View blog
  • Posts: 2,690
  • Joined: 18-December 08

Re: Help with Java.

Posted 09 February 2010 - 07:38 PM

If you declare a variable in one method (such as localObject), you cannot use it in another (at least, in the way you try to)
Was This Post Helpful? 0
  • +
  • -

#13 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8315
  • View blog
  • Posts: 31,836
  • Joined: 06-March 08

Re: Help with Java.

Posted 09 February 2010 - 09:04 PM

Please use more descriptive topic title.
"Help with Java" is kind of useless in this forum and rule #5 specifies: "Give your topic a descriptive title, NOT "Help" or "Plz Help Me" or "I'm a noob""
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1