文本框
package com.yuecheng.lesson01;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class TestText01 {
public static void main(String[] args) {
A5 a5 = new A5();
}
}
class A5 extends Frame {
public A5(){
TextField textField = new TextField();
add(textField);
A6 a6 = new A6();
textField.addActionListener(a6);
textField.setEchoChar('*');
setVisible(true);
pack();
}
}
class A6 implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
TextField field=(TextField) e.getSource();
System.out.println(field.getText());
field.setText("");
}
}