输入框事件监听
e.getText返回的是一个Object对象,向下转型成TextField类的对象
public class TestText01 { public static void main(String[] args) { new MyFrame(); } } class MyFrame extends Frame{ public MyFrame(){ TextField textField = new TextField(); this.add(textField); textField.addActionListener(new MyActionListener02()); setVisible(true); setSize(200,200); } } class MyActionListener02 implements ActionListener{ @Override public void actionPerformed(ActionEvent e) { TextField Field=(TextField) e.getSource(); System.out.println(Field.getText()); } }