import java.awt.*;
import java.awt.event.*;public class TFActionEvent{ public static void main(String[] args) {
Frame f=new Frame("TFActionEvent");
f.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent windowevent)
{
System.exit(0);
}
});
TextField tf=new TextField();
f.add(tf);
tf.addActionListener(new TFActionListrner());
//tf.setEchoChar('*');
f.setLocation(300,300);
f.pack();
f.setVisible(true);
}
}
class TFActionListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
TextField tf= (TextField)e.getSource();
System.out.println(tf.getText());
tf.setText("");
}
}
这段代码运行的时候,在TextField框中输入字符。按回车在DOC下却没有任何显示。请高手们帮忙看下是什么问题?谢谢
import java.awt.event.*;public class TFActionEvent{ public static void main(String[] args) {
Frame f=new Frame("TFActionEvent");
f.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent windowevent)
{
System.exit(0);
}
});
TextField tf=new TextField();
f.add(tf);
tf.addActionListener(new TFActionListrner());
//tf.setEchoChar('*');
f.setLocation(300,300);
f.pack();
f.setVisible(true);
}
}
class TFActionListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
TextField tf= (TextField)e.getSource();
System.out.println(tf.getText());
tf.setText("");
}
}
这段代码运行的时候,在TextField框中输入字符。按回车在DOC下却没有任何显示。请高手们帮忙看下是什么问题?谢谢
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货