📄 usetextarea.java
字号:
import java.awt.*;
import java.awt.event.*;
public class UseTextArea{
public static void main(String args[]){
MyFrame f=new MyFrame();
f.setSize(330,300);
f.setBackground(Color.lightGray);
f.setLayout(new FlowLayout());
f.show();
}
}
class MyFrame extends Frame implements TextListener{
TextArea ta1,ta2;
public MyFrame(){
super("my frame");
ta1=new TextArea(5,20);
ta2=new TextArea(5,20);
ta1.addTextListener(this);
setLayout(new FlowLayout());
add(ta1); add(ta2);
this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
dispose();
System.exit(0);
}});
}
public void textValueChanged(TextEvent e){
if(e.getSource()==ta1)
ta2.setText(ta1.getText());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -