rendered paste bodypackage com.io9labs.ircbot;import java.text.SimpleDateFormat;import java.util.*;import javax.swing.*;import java.awt.*;import java.awt.event.*;import com.pagosoft.plaf.*;import com.pagosoft.plaf.themes.*;public class BotGUI implements ActionListener, GUIStrings { io9Bot bot = new io9Bot(); public boolean isConnected = false; public final static String PROGNAME = "9otGooey v1.01"; public final static String COPYRITE = "Copyright (c) io9/io9Labs"; public static JTextArea console = new JTextArea(20,30); public static JScrollPane scroll = new JScrollPane(console, 22, 31); public static Console cons = new Console(console, scroll); private static void initLookAndFeel() { try { PgsLookAndFeel.setCurrentTheme(new VistaTheme()); UIManager.setLookAndFeel(new com.pagosoft.plaf.PgsLookAndFeel()); } catch (UnsupportedLookAndFeelException e) { log("Couldn't use the PgsLookAndFeel"); log("Did you tamper with 9otGUI?"); e.printStackTrace(); System.exit(1); } catch (Exception e) { log("Couldn't use the PgsLookAndFeel"); log("Did you tamper with 9otGUI?"); e.printStackTrace(); System.exit(1); } } public static synchronized void log(String message) { message = new StringBuilder().append (new SimpleDateFormat("~=hh:mm:ss a=~").format(new Date())) .append (" --> ").append (message).toString(); cons.println(message); System.out.println(message); } public BotGUI() { // make us pretty pl0x initLookAndFeel(); // JFrame pl0x? JFrame frame = new JFrame(PROGNAME + ".\\.+-~-+./." + COPYRITE); frame.setDefaultCloseOperation(3); // JFrame.EXIT_ON_CLOSE = 3 JFrame.setDefaultLookAndFeelDecorated(true); //let's make our menus... JMenuBar menuBar; JMenu main, channelSubmenu, serverSubmenu; JMenuItem exit, connect, disconnect, join, leave; menuBar = new JMenuBar(); main = new JMenu("File"); main.setMnemonic(KeyEvent.VK_F); main.getAccessibleContext().setAccessibleDescription( "Use this menu to connect/disconnect to servers, and to manage channels."); menuBar.add(main); serverSubmenu = new JMenu("Server"); serverSubmenu.setMnemonic(KeyEvent.VK_S); connect = new JMenuItem("Connect to a Server"); connect.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.ALT_MASK)); connect.addActionListener(this); serverSubmenu.add(connect); disconnect = new JMenuItem("Disconnect from the server"); disconnect.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, ActionEvent.ALT_MASK)); disconnect.addActionListener(this); serverSubmenu.add(disconnect); main.add(serverSubmenu); channelSubmenu = new JMenu("Channel"); channelSubmenu.setMnemonic(KeyEvent.VK_H); join = new JMenuItem("Join a Channel"); join.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_J, ActionEvent.ALT_MASK)); join.addActionListener(this); channelSubmenu.add(join); leave = new JMenuItem("Part(Leave) Channel"); leave.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.ALT_MASK)); leave.addActionListener(this); channelSubmenu.add(leave); main.add(channelSubmenu); main.addSeparator(); exit = new JMenuItem("Exit"); exit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.ALT_MASK)); exit.addActionListener(this); main.add(exit); frame.setJMenuBar(menuBar); frame.setPreferredSize(new Dimension(765, 503)); scroll.setPreferredSize(new Dimension(765, 503)); console.setForeground(Color.red); console.setBackground(Color.black); frame.add(scroll); frame.pack(); frame.setVisible(true); } public void displayServerSelect() { String server = JOptionPane.showInputDialog(this, "Please enter your server's Address..."); if (server == null) log("joinServer() - Bad input...."); else { isConnected = true; bot.log("joinServer() - Connecting to server: " + server + " on port 6667"); try { bot.connect(server); } catch(NickAlreadyInUseException e1) { log("Exception NickAlreadyInUseException caught!"); log("Please change you nick and try connecting again"); } catch(IrcException e2) { log("IRCException caught!"); log("Please try connecting again..."); } catch(Exception e3) { e3.printStackTrace(); } } } public void displayJoinChannel() { try { String channel = JOptionPane.showInputDialog(this, "Please enter channel to join."); if (channel == null) { log("joinChan() - Please enter a valid channel name"); } else if(!channel.startsWith("#")) { String newChannel = "#" + channel; channel = newChannel; bot.joinChannel(channel); log("joinChannel() - Joining channel: " + channel); } else { bot.joinChannel(channel); log("joinChan() - Joining Channel" + channel); } } catch (Exception e) { e.printStackTrace(); } } public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); log(cmd); if(cmd != null) { if(cmd.equalsIgnoreCase("Exit")) { if(isConnected) { for(int i = 0; i == DISCONNECT_AND_EXIT.length; i++) { log(DISCONNECT_AND_EXIT[i]); } bot.disconnect(); System.exit(0); } else { log("Exiting"); System.exit(0); } } } else if(cmd.equalsIgnoreCase("Connect to a server")) { displayServerSelect(); } } public static void createAndShowGUI() { JFrame.setDefaultLookAndFeelDecorated(true); BotGUI gui = new BotGUI(); } public static void main(String[] args) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { createAndShowGUI(); } }); }}