📄 textexample.java
字号:
import java.awt.*;
import java.awt.event.*;
public class TextExample
implements ActionListener,TextListener {
Frame f;
TextField tf1;
TextArea ta1,ta2;
static public void main(String args[]) {
TextExample te = new TextExample();
te.go();
}
public void go() {
f = new Frame("Text Example");
f.setLayout( new FlowLayout() );
tf1 = new TextField("Init",20);
tf1.addActionListener(this);
tf1.addTextListener(this);
ta1 = new TextArea("Initial text",4,30);
ta1.addTextListener(this);
ta2 = new TextArea("Only horizontal scrollbar ",4,30,
TextArea.SCROLLBARS_HORIZONTAL_ONLY);
f.add(tf1);
f.add(ta1);
f.add(ta2);
f.setSize(300,300);
f.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
ta2.append("\nActionPerformed");
}
public void textValueChanged(TextEvent e) {
ta2.append("\nTextValueChanged");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -