rendered paste body/* worldSwitcher.java
* Created: Friday, December 28, 2007
* By: Mod Adam
* Description: This program will allow a user to click on
* a RuneScape World, and it will then open the users
* browser and bring you to that World. */
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.Container;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import javax.swing.JTabbedPane;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JComponent;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import javax.swing.colorchooser.*;
import java.awt.event.KeyEvent;
public class worldSwitcher extends JFrame {
public static void main(String[] args) {
worldSwitcher frame = new worldSwitcher();
frame.setDefaultLookAndFeelDecorated(true);
frame.setTitle("RuneScape World Switcher by Mod Adam"); //Title
frame.setSize(750, 710); //Width, Height
frame.setVisible(true);
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public worldSwitcher() {
JPanel panel = new JPanel();
JPanel panel2 = new JPanel();
JPanel panel3 = new JPanel();
ImageIcon icon = createImageIcon("images/middle.gif");
JTabbedPane pane = new JTabbedPane();
JMenuBar menu = new JMenuBar();
JMenu file = new JMenu("File");
JMenuItem exit = new JMenuItem("Exit");
add(pane, "Center");
//panel.setLayout(new FlowLayout());
add(menu, "North");
menu.add(file);
file.add(exit);
pane.addTab("Free Worlds", icon, panel, "Free RuneScape Worlds (F2P)");
pane.addTab("Member Worlds", icon, panel2, "Member RuneScape Worlds (P2P)");
pane.addTab("All Worlds", icon, panel3, "All RuneScape Worlds (F2P) & (P2P)");
int[] memberWorldID = {2, 6, 9, 12, 18, 22, 23, 24, 26, 27, 28, 31, 36,
39, 42, 44, 45, 46, 48, 53, 54, 56, 58, 59, 64,
65, 66, 69, 70, 71, 76, 77, 78, 79, 82, 83, 84,
88, 89, 91, 92, 97, 98, 99, 100, 103, 104, 110,
111, 112, 114, 115, 116, 121, 124, 129, 130, 131,
132, 137, 138, 143, 144, 145, 151, 157, 158, 159};
int[] freeWorldID = {1, 3, 4, 5, 7, 8, 10, 11, 13, 14, 15, 16, 17, 19, 20,
21, 25, 29, 30, 32, 33, 34, 35, 37, 38, 40, 41, 43,
47, 50, 51, 52, 55, 57, 61, 62, 63, 67, 68, 72, 74,
75, 80, 81, 85, 86, 87, 90, 93, 94, 95, 96, 101,
102, 105, 106, 107, 108, 109, 113, 117, 118, 119,
123, 125, 126, 127, 128, 133, 134, 136, 141, 142,
149, 152, 153, 154, 155};
Arrays.sort(memberWorldID);
Arrays.sort(freeWorldID);
int[] worlds = new int[memberWorldID.length + freeWorldID.length];
System.arraycopy(memberWorldID, 0, worlds, 0, memberWorldID.length);
System.arraycopy(freeWorldID, 0, worlds, memberWorldID.length, freeWorldID.length);
for (int x = 0; x < freeWorldID.length; x++) {
JButton fWorld = new JButton("World " + freeWorldID[x]);
panel.add(fWorld);
}
for (int x = 0; x < memberWorldID.length; x++) {
JButton mWorld = new JButton("<html><font color=yellow>World " + memberWorldID[x] + "</fontcolor></html>");
panel2.add(mWorld);
}
int x = 0;
int m = 0;
// Next While, needs some work. Displays Both but not in the right order. Takes one from free, then one from member then another from free.. etc.
while (x < memberWorldID.length && m < freeWorldID.length) {
Arrays.sort(worlds);
JButton afWorld = new JButton("World " + freeWorldID[m]);
JButton amWorld = new JButton("<html><font color=yellow>World " + memberWorldID[x] + "</fontcolor></html>");
x++;
m++;
panel3.add(afWorld);
panel3.add(amWorld);
}
}
protected static ImageIcon createImageIcon(String path) {
java.net.URL imgURL = worldSwitcher.class.getResource(path);
if (imgURL != null) {
return new ImageIcon(imgURL);
} else {
System.err.println("Couldn't find file: " + path);
return null;
}
}
}