今早上起的很早啊,呵呵,学习了,还不错。。不知道为什么啊就是到了四点就睡不着了,所以就起来了,应该是昨晚上睡的太早了。我自己加上的窗口关闭的小应用,得记下来,今天一定能够熟练的掌握这个东西。
import java.awt.*;
import java.awt.event.*;
public class TFFrame extends Frame{
TFFrame(){
TextField tf = new TextField();
add(tf);
Monitor3 bh= new Monitor3();
add(tf);
tf.addActionListener(bh);
pack();
setVisible(true);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.out.println("Atention");
System.out.println("Program is Closed.");
System.exit(0);
}
});
}
public static void main(String args[]){
new TFFrame();
}
}
class Monitor3 implements ActionListener{
public void actionPerformed(ActionEvent e){
TextField tf = (TextField)(e.getSource());
System.out.println(tf.getText());
tf.setText("");
}
}
Tags -
textfieldjava
文章来源:
http://www.tt-shopping.com/kevinlau/read.php/93.htm