📄 kongjian.java
字号:
import java.awt.*;
import java.awt.event.*;
public class test8 extends java.applet.Applet implements ActionListener,TextListener
{
Label lab1,lab2;
Button but1,but2;
TextArea ta;
TextField text1,text2;
String str;
public void init()
{
lab1=new Label("输入姓名");
lab2=new Label("输入年龄");
but1=new Button("保存");
but2=new Button("退出");
but1.addActionListener(this);
but2.addActionListener(this);
text1=new TextField(10);
text1.addTextListener(this);
text2=new TextField(10);
text2.addTextListener(this);
ta=new TextArea("个人资料:",10,15);
ta.addTextListener(this);
ta.setEditable(false);
add(lab1);
add(text1);
add(lab2);
add(text2);
add(but1);
add(but2);
add(ta);
}
public void actionPerformed(ActionEvent e)
{
if(e.getActionCommand()=="保存")
{
str='\n'+text1.getText()+'\n'+text2.getText()+'\n';
ta.append(str);
text1.setText("");
text2.setText("");
repaint();
}
else if(e.getActionCommand()=="退出")
{
System.exit(0);
}
}
public void textValueChanged(TextEvent e)
{
repaint();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -