Difficulty: 2/10
Required: A Brain, Knowledge of Copy+Paste
Okay, First thing is first. I know i hate looking at the black box with the white letters thinking to myself i wanted to make an irc bot not read the *censored*ing matrix, so i'm sure you all would probably like to have something a little neater to look at when you need to check your bots status.
Basically this whole guide is copying and pasting to save time for both me and you.
First what your going to do is make a new class named GUI
inside GUI class copy and paste this
import javax.swing.JFrame;
public class GUI extends javax.swing.JFrame {
public GUI() {
initComponents();
}
@SuppressWarnings("unchecked")
public void initComponents() {
Title = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
ChatLog = new javax.swing.JTextArea();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
Title.setFont(new java.awt.Font("Kristen ITC", 1, 18));
Title.setText("CHANGE THIS TO THE TITLE OF YOUR BOT");
ChatLog.setColumns(20);
ChatLog.setRows(5);
ChatLog.setEditable(false);
ChatLog.append("\n");
jScrollPane1.setViewportView(ChatLog);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(211, Short.MAX_VALUE)
.addComponent(Title, javax.swing.GroupLayout.PREFERRED_SIZE, 350, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(190, 190, 190))
.addGroup(layout.createSequentialGroup()
.addGap(19, 19, 19)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 711, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(21, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(Title)
.addGap(18, 18, 18)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 246, Short.MAX_VALUE)
.addContainerGap())
);
pack();
}
public void ShowComponents() {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new GUI().setVisible(true);
}
});
}
public static javax.swing.JTextArea ChatLog;
private javax.swing.JLabel Title;
private javax.swing.JScrollPane jScrollPane1;
}
Save and exit or if you have Notepad ++ open up MyBot Class
under
public class MyBot extends PircBot {
add
static GUI currentGUI = new GUI();
next you're going to find
public MYBot() {
and add
currentGUI.ShowComponents();
okay now above the last } in public mybot you are going to add this
@Override
public void log(String line) {
currentGUI.ChatLog.append(line + "\n");
currentGUI.ChatLog.setCaretPosition(currentGUI.ChatLog.getText().length());
}
and there you have it a nice little gui to have you're bot show on. for anyone with onMessage or anything like that who wants it logged you would do
@Override
public void onMessage(String channel, String sender, String login, String hostname, String message) {
log(message);
}
Thanks
Bo The Pro
MSN: Bstephenson7@hotmail.com
Feedback is great.
Last Updated Wednesday, May 12 2010 @ 02:32 PM CDT|932 Hits 