📄 mytextfield2.java
字号:
import java.awt.*;
import java.awt.event.*;
public class MyTextField2{
Frame f;
TextField t1, t2;
public MyTextField2(){
Frame f = new Frame();
f.addWindowListener(new MyWindowAdapter());
t1 = new TextField(30);
t2 = new TextField(30);
t1.addActionListener(new MyActionImpl());
t2.addActionListener(new MyActionImpl());
t1.setEchoChar('*');
f.setLayout(new FlowLayout());
f.setSize(300, 100);
f.add(t1);
f.add(t2);
f.setVisible(true);
}
public static void main(String[] args){
MyTextField2 mt = new MyTextField2();
}
class MyActionImpl implements ActionListener{
public void actionPerformed(ActionEvent e){
if (e.getSource()==t1)
t2.setText("The End !");
}
}
class MyWindowAdapter extends WindowAdapter{
public void windowClosing(WindowEvent e){
System.exit(0);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -