1 public class Test {
2
3 public static void main(String[] args) {
4 // TODO Auto-generated method stub
5 Frame f = new Frame();
6 //关闭窗口
7 f.addWindowListener(new WindowAdapter() {
8
9 @Override
10 public void windowClosing(WindowEvent e) {
11 System.exit(0);
12 }
13
14 });
15 //设置尺寸
16 f.setSize(500, 600);
17 //设置出现的位置
18 f.setLocation(100, 100);
19 //修改默认布局
20 f.setLayout(null);
21
22 //设置文本框
23 TextField text = new TextField();
24 text.setSize(200,30);
25 text.setLocation(200, 200);
26 text.setEchoChar('*');
27 f.add(text);
28
29 //设置标签
30 Label l = new Label("账号");
31 l.setLocation(150, 200);
32 l.setSize(100, 30);
33 f.add(l);
34
35 //设置按钮
36 Button b = new Button("确定");
37 b.setSize(100, 50);
38 b.setLocation(200, 250);
39 f.add(b);
40
41 //显示窗体
42 f.setVisible(true);
43
44 }
45
46
47
48 }