?? logindemo.java
字號:
import java.awt.*;
import java.awt.event.*;
public class LoginDemo extends Frame implements ActionListener
{
Label lbl1;
Label lbl2;
Label lbl3;
TextField tf1;
TextField tf2;
Button bt1;
Button bt2;
LoginDemo()
{
super("Login Window");
lbl1=new Label("name");
lbl2=new Label("age");
lbl3=new Label(" ");
tf1=new TextField(20);
tf2=new TextField(20);
bt1=new Button("ok");
bt2=new Button("canel");
this.setLayout(new GridLayout(4,2));
this.add(lbl1);
this.add(tf1);
this.add(lbl2);
this.add(tf2);
this.add(bt1);
this.add(bt2);
this.add(lbl3);
bt1.addActionListener(this);
bt2.addActionListener(this);
this.setSize(200,300);
this.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
Object obj=e.getSource();
if(obj==bt1)
lbl3.setText("name:"+tf1.getText()+(char)13+(char)10+"age:"+tf2.getText());
else if(obj==bt2)
{
System.exit(0);
this.dispose();
}
}
public static void main(String args[])
{
new LoginDemo();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -