-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBorderLayout_t.java
More file actions
46 lines (33 loc) · 886 Bytes
/
BorderLayout_t.java
File metadata and controls
46 lines (33 loc) · 886 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package com.bj;
import java.awt.*;
import javax.swing.*;
public class BorderLayout_t extends JFrame {
//定义组件
JButton jb1,jb2,jb3,jb4,jb5;
public static void main(String[] args) {
// TODO Auto-generated method stub
BorderLayout_t b=new BorderLayout_t();
}
public BorderLayout_t(){
//创建组件
jb1=new JButton("中部");
jb2=new JButton("北部");
jb3=new JButton("东部");
jb4=new JButton("南部");
jb5=new JButton("西部");
//添加组件
this.add(jb1,BorderLayout.CENTER);
this.add(jb2,BorderLayout.NORTH);
this.add(jb3,BorderLayout.EAST);
this.add(jb4,BorderLayout.SOUTH);
this.add(jb5,BorderLayout.WEST);
//设置属性
this.setTitle("边界案例");
this.setSize(400, 500);
this.setLocation(200,300);
//关闭窗口,操作关闭窗口
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//设置窗体可见
this.setVisible(true);
}
}