java TFActionEvent
import java.awt.*;import java.awt.event.*;
//import java.util.*;
//import java.lang.*;
//import static net.mindview.util.Print.*;
public class TFActionEvent
{
public static void main(String[] args)
{
new TFFrame();
}
}
class TFFrame extends Frame
{
TFFrame()
{
TextField tf = new TextField();
add(tf);
tf.addActionListener(new TFActionListener());
pack();
setVisible(true);
}
}
class TFActionListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
TextField tf = (TextField)e.getSourse();
System.out.println(tf.getText());
tf.setText("");
}
}
编译时会出现以下结果:
符号: 方法 getSourse()
位置: 类 java.awt.enevt.ActionEvent
Textfield tf = (TextField)e.getSourse();
搜索更多相关的解决方案:
java
----------------解决方案--------------------------------------------------------
getSource()
----------------解决方案--------------------------------------------------------