日期:2014-05-20 浏览次数:20719 次
import java.awt.*;
import java.awt.event.*;
public class Chat
{
Frame f = new Frame("我和你");
TextField tfIP = new TextField(15);
List lst = new List(6);
public static void main(String[] args)
{
Chat chat= new Chat();
chat.init();
}
public void init()
{
f.setSize(300,300);
f.add(lst);
Panel p = new Panel();
p.setLayout(new BorderLayout());
p.add("West",tfIP);
TextField tfData = new TextField(20);
p.add("East",tfData);
p.add("South",p);
f.setVisible(true);
f.setResizable(false);
f.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e)
{
f.setVisible(false);
f.dispose();
System.exit(0);
}
});
tfData.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
((TextField)e.getSource()).setText("");
}
});
}
}