-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMultiLayout.java
More file actions
70 lines (47 loc) · 1.06 KB
/
MultiLayout.java
File metadata and controls
70 lines (47 loc) · 1.06 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
* 多组件布局
*/
package com.bj;
import javax.swing.*;
import java.awt.*;
public class MultiLayout extends JFrame {
//定义组件
JPanel jp1,jp2;
JButton jb1,jb2,jb3,jb4,jb5,jb6;
public static void main(String[] args) {
// TODO Auto-generated method stub
MultiLayout m=new MultiLayout();
}
public MultiLayout(){
//创建组件
//Jpanel布局默认是FlowLayout
jp1=new JPanel();
jp2=new JPanel();
jb1=new JButton("西瓜");
jb2=new JButton("苹果");
jb3=new JButton("香蕉");
jb4=new JButton("葡8萄");
jb5=new JButton("芒果");
jb6=new JButton("鸭梨");
//设置布局
//添加组件
jp1.add(jb1);
jp1.add(jb2);
jp1.add(jb3);
jp2.add(jb4);
jp2.add(jb5);
//把Panel加入JFrame
this.add(jp1,BorderLayout.NORTH);
this.add(jb6);
this.add(jp2, BorderLayout.SOUTH);
//设置大小
this.setTitle("MultiLayout");
this.setSize(500, 500);
this.setLocation(200,200);
//设置
//this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//this.location(200,300);
//设置可见
this.setVisible(true);
}
}