📄 abc.java
字号:
import java.awt.*;
import java.applet.Applet;
import java.awt.event.*;
public class abc extends Applet implements ActionListener
{
public Label nameLabel,passwardLabel,addressLabel,titleLabel,sexLabel;
public TextField name,passward;
public Choice address;
public Button button;
public TextArea txtArea;
public Checkbox chb1,chb2;
public CheckboxGroup chb;
public void init()
{
setLayout(null);
titleLabel = new Label("用户注册");
titleLabel.setBackground(Color.orange);
nameLabel = new Label("用户名:");
nameLabel.setBackground(Color.green);
nameLabel.setForeground(Color.red);
passwardLabel = new Label("密码:");
passwardLabel.setBackground(Color.green);
passwardLabel.setForeground(Color.red);
addressLabel = new Label("地址:");
addressLabel.setBackground(Color.green);
addressLabel.setForeground(Color.red);
name = new TextField("");
passward = new TextField("");
passward.setEchoChar('*');
address = new Choice();
address.addItem("北京");
address.addItem("上海");
address.addItem("南京");
address.addItem("合肥");
address.addItem("芜湖");
button = new Button("提交");
txtArea = new TextArea(3,5);
txtArea.setEditable(false);
sexLabel = new Label("性别:");
sexLabel.setBackground(Color.green);
sexLabel.setForeground(Color.red);
chb = new CheckboxGroup();
chb1 = new Checkbox("男",chb,true);
chb2 = new Checkbox("女",chb,false);
titleLabel.setLocation(280,0);titleLabel.setSize(80,20);
nameLabel.setLocation(200,30);nameLabel.setSize(40,20);
name.setLocation(250,30);name.setSize(200,20);
passwardLabel.setLocation(200,60);passwardLabel.setSize(40,20);
passward.setLocation(250,60);passward.setSize(200,20);
sexLabel.setLocation(200,90);sexLabel.setSize(40,20);
chb1.setLocation(250,90);chb1.setSize(30,30);
chb2.setLocation(300,90);chb2.setSize(30,30);
addressLabel.setLocation(200,120);addressLabel.setSize(40,20);
address.setLocation(250,120);address.setSize(70,20);
button.setLocation(250,150);button.setSize(80,30);
txtArea.setLocation(200,200);txtArea.setSize(250,80);
button.addActionListener(this);
add(nameLabel);add(name);
add(titleLabel);add(sexLabel);
add(passwardLabel);add(passward);
add(chb1);add(chb2);
add(addressLabel);add(address);
add(button);add(txtArea);
}
public void actionPerformed(ActionEvent e)
{
txtArea.setText("用户名:"+name.getText()+'\n'+"密码:"+passward.getText()+'\n'+"性别:"+chb.getSelectedCheckbox()+'\n'+"地址:"+address.getSelectedItem());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -