-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path程序8_11.java
50 lines (45 loc) · 1.56 KB
/
程序8_11.java
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
import java.awt.*;
import javax.swing.*;
public class 程序8_11 {
private JFrame frame;
private Box b1, b2, b3, b4;
public static void main(String[] args) {
程序8_11 that = new 程序8_11();
that.go();
}
void go() {
frame = new JFrame("Glue and Strut example");
Container contentPane = frame.getContentPane();
contentPane.setLayout(new GridLayout(4,1));
b1 = Box.createHorizontalBox();
b1.add(new JLabel("Box 1 : "));
b1.add(new JButton("Yes"));
b1.add(new JButton("No"));
b1.add(new JButton("Cancel"));
b2 = Box.createHorizontalBox();
b2.add(new JLabel("Box 2 : "));
b2.add(new JButton("Yes"));
b2.add(new JButton("No"));
b2.add(Box.createHorizontalGlue());
b2.add(new JButton("Cancel"));
b3 = Box.createHorizontalBox();
b3.add(new JLabel("Box 3 : "));
b3.add(new JButton("Yes"));
b3.add(new JButton("No"));
b3.add(Box.createHorizontalStrut(20));
b3.add(new JButton("Cancel"));
b4 = Box.createHorizontalBox();
b4.add(new JLabel("Box 4 : "));
b4.add(new JButton("Yes"));
b4.add(new JButton("No"));
b4.add(Box.createRigidArea(new Dimension(50,90)));
b4.add(new JButton("Cancel"));
contentPane.add(b1);
contentPane.add(b2);
contentPane.add(b3);
contentPane.add(b4);
frame.setSize(300,200);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}