forked from liujiboy/Java_Course
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComplexLayoutDemo.java
More file actions
50 lines (45 loc) · 1.55 KB
/
ComplexLayoutDemo.java
File metadata and controls
50 lines (45 loc) · 1.55 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
package cqu.gui;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class ComplexLayoutDemo extends JFrame{
private static final long serialVersionUID = -6700565162528866686L;
private JPanel centerPanel=new JPanel();
private JPanel leftPanel=new JPanel();
private JPanel rightPanel=new JPanel();
private JButton first=new JButton("first");
private JButton second=new JButton("second");
private JButton third=new JButton("third");
private JButton north=new JButton("north");
private JButton south=new JButton("south");
private JButton east=new JButton("east");
private JButton west=new JButton("west");
private JButton center=new JButton("center");
public ComplexLayoutDemo()
{
setLayout(new BorderLayout());
this.add(centerPanel,BorderLayout.CENTER);
centerPanel.setLayout(new GridLayout(1,2));
centerPanel.add(leftPanel);
centerPanel.add(rightPanel);
leftPanel.setLayout(new FlowLayout());
leftPanel.add(first);
leftPanel.add(second);
leftPanel.add(third);
rightPanel.setLayout(new BorderLayout());
rightPanel.add(north,BorderLayout.NORTH);
rightPanel.add(south,BorderLayout.SOUTH);
rightPanel.add(east,BorderLayout.EAST);
rightPanel.add(west,BorderLayout.WEST);
rightPanel.add(center,BorderLayout.CENTER);
}
public static void main(String[] args) {
ComplexLayoutDemo demo=new ComplexLayoutDemo();
demo.setSize(400, 400);
demo.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
demo.setVisible(true);
}
}