rendered paste bodyimport java.awt.BorderLayout;
import javax.swing.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
import java.util.*;
class ChatFrame extends JFrame {
DataInputStream is;
PrintStream os;
String line;
String line2;
JTextField input;
public ChatFrame() {
Socket myClient;
try {
myClient = new Socket("irc.freenode.net",6667);
is = new DataInputStream(myClient.getInputStream());
os = new PrintStream(myClient.getOutputStream());
} catch (Exception e) {
System.out.println("Fatal Connection Error!! Exception caught: " + e);
}
os.println("USER DrIRC 8 * : DrIRC v0.1 Alpha");
os.println("NICK DrIRC");
os.println("JOIN #betatest");
setTitle("DrIRC");
setLayout(new BorderLayout());
setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(550,400);
setVisible(true);
JTextArea textarea = new JTextArea("# Welcome to DrIRC Alpha.\n# Connecting to server...\n", 30, 50);
JScrollPane viewer = new JScrollPane(textarea);
add(viewer, BorderLayout.PAGE_START);
input = new JTextField(20);
add(input, BorderLayout.PAGE_END);
input.addActionListener(this);
pack();
while (true) {
try {
line = is.readLine();
if (line.indexOf("VERSION") >= 0) {
os.println("\001VERSION DrIRC:0.3 Alpha:Platform Independent\001");
}
if (line == null) {
textarea.setText(textarea.getText() + "# Disconnected from server.");
}
} catch (Exception e) {
System.out.println("Read/Write error: "+e);
}
textarea.setText(textarea.getText() + line + "\n");
}
}
public void actionPerformed(ActionEvent e) {
String value = input.getText();
os.println(value);
}
// The compiler errors returned by this code are:
// addActionListener(java.awt.event.ActionListener) in javax.swing.JTextField cannot be applied to (ChatFrame)
// cannot find symbol method indexOf(java.lang.String)
}