I can't get the scrollpane to appear here:
package oldschool.runescape.com; import java.awt.EventQueue; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; import java.net.URLConnection; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import java.util.regex.Pattern; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTree; import javax.swing.border.EmptyBorder; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultTreeModel; public class Worlds extends JFrame { private static final long serialVersionUID = 445871530648558835L; private JPanel contentPane; private Map<String, Integer> worlds = new HashMap<String, Integer>(); private String site = "http://oldschool.runescape.com/slu.ws?order=WpMLA"; /** * Launch the application. */ public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { Worlds frame = new Worlds(); frame.setVisible(true); frame.prepareWorlds(); } catch (Exception e) { e.printStackTrace(); } } }); } private void prepareWorlds() { final Pattern pattern = Pattern.compile("d.write"); try { URL url = new URL(site); URLConnection curl = url.openConnection(); curl.setDoInput(true); InputStream instr = curl.getInputStream(); String s; if (instr != null) { BufferedReader in = new BufferedReader(new InputStreamReader( instr)); while ((s = in.readLine()) != null) { if (pattern.matcher(s).find()) { while ((s = in.readLine()) != null) { if (s == null || s.equalsIgnoreCase("") || s.equalsIgnoreCase(" ")) continue; if (s.equals("</script>")) break; String data = s; final Pattern school = Pattern.compile("oldschool.*?"); if (school.matcher(data).find()) { String[] newStrings = data.split("\""); String name = newStrings[1]; int count = Integer.parseInt(data.split(",")[4]); worlds.put(name, count); } } } } } for (Entry<String, Integer> v : worlds.entrySet()) { dropsNode.add(new DefaultMutableTreeNode(v.getKey())); } } catch (Throwable t) { t.printStackTrace(); } } private DefaultMutableTreeNode dropsNode = new DefaultMutableTreeNode("Worlds"); private DefaultTreeModel dropsTreeModel = new DefaultTreeModel(dropsNode); private JTree tree = new JTree(); private JScrollPane treeScroll = new JScrollPane(); /** * Create the frame. */ public Worlds() { prepareWorlds(); setTitle("07 World Picker"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 414, 295); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); JButton btnGo = new JButton("GO!"); btnGo.setBounds(125, 222, 129, 23); contentPane.add(btnGo); JLabel lblPickAWorld = new JLabel("Pick a world:"); lblPickAWorld.setBounds(10, 11, 129, 23); contentPane.add(lblPickAWorld); tree.setBounds(125, 14, 129, 114); tree.setModel(dropsTreeModel); treeScroll.add(tree); contentPane.add(tree); btnGo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { //RS2Loader.startUp(tree.getSelectionModel().getSelectionPath().getLastPathComponent()); } catch (Exception e1) { e1.printStackTrace(); } setVisible(false); } }); } }
It appears like this: