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 javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class worldSwitcher extends JFrame implements ActionListener {
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("");
JTabbedPane pane = new JTabbedPane();
JMenuBar menu = new JMenuBar();
JMenu file = new JMenu("File");
JMenu rs = new JMenu("RuneScape");
JMenu code = new JMenu("Programming");
JMenu use = new JMenu("Useful Links");
JMenu cred = new JMenu("Credits");
JMenuItem exit = new JMenuItem("Exit");
JMenuItem forum = new JMenuItem("Forums");
JMenuItem hs = new JMenuItem("Hiscores");
JMenuItem rhq = new JMenuItem("Rune Hq");
JMenuItem cursed = new JMenuItem("Cursed Uploads");
JMenuItem coders = new JMenuItem("CodersRus");
JMenuItem pwnd = new JMenuItem("Pwnds");
JMenuItem mopar = new JMenuItem("MoparScape");
JMenuItem mitb = new JMenuItem("Moparisthebest");
JMenuItem view = new JMenuItem("View Credits");
JMenuItem upp = new JMenuItem("Uppit");
JMenuItem paste = new JMenuItem("Pastebin");
JMenuItem home = new JMenuItem("RuneScape Homepage");
home.addActionListener(this);
add(pane, "Center");
add(menu, "North");
//panel.setLayout(new FlowLayout());
menu.add(file);
menu.add(rs);
menu.add(code);
menu.add(use);
menu.add(cred);
file.add(exit);
rs.add(home);
rs.add(forum);
rs.add(hs);
rs.add(rhq);
code.add(coders);
code.add(pwnd);
code.add(mopar);
code.add(mitb);
use.add(cursed);
use.add(upp);
use.add(paste);
cred.add(view);
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);
}
home.addActionListener(this);
paste.addActionListener(this);
upp.addActionListener(this);
cursed.addActionListener(this);
pwnd.addActionListener(this);
mitb.addActionListener(this);
mopar.addActionListener(this);
rhq.addActionListener(this);
coders.addActionListener(this);
hs.addActionListener(this);
forum.addActionListener(this);
}
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;
}
}
//All buttons work but RS Homepage opens twice...
//I also have yet to make Worlds open. Got an idea how?
public void actionPerformed(ActionEvent e) {
try {
if(e.getActionCommand().equals("RuneScape Homepage")) {
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler http://www.runescape.com");
}
if(e.getActionCommand().equals("CodersRus")) {
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler http://www.codersrus.org/");
}
if(e.getActionCommand().equals("Forums")) {
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler http://forum.runescape.com/forums.ws");
}
if(e.getActionCommand().equals("Hiscores")) {
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler http://hiscore.runescape.com/hiscores.ws");
}
if(e.getActionCommand().equals("Rune Hq")) {
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler http://www.runehq.com/");
}
if(e.getActionCommand().equals("Cursed Uploads")) {
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler http://choobisle.no-ip.info:8080/index.php/");
}
if(e.getActionCommand().equals("Pwnds")) {
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler http://www.pwnds.info/");
}
if(e.getActionCommand().equals("MoparScape")) {
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler http://www.moparscape.org/smf/");
}
if(e.getActionCommand().equals("Moparisthebest")) {
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler http://www.moparisthebest.com/smf/");
}
if(e.getActionCommand().equals("Uppit")) {
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler http://www.uppit.com/");
}
if(e.getActionCommand().equals("Pastebin")) {
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler http://www.pastebin.ca/");
}
}
catch(Exception exception) { }
}
}