-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathBoxLayout1.java
More file actions
44 lines (35 loc) · 1.01 KB
/
BoxLayout1.java
File metadata and controls
44 lines (35 loc) · 1.01 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
package gui;
/**
* RUN:
* javac gui/BoxLayout1.java && java gui.BoxLayout1
* OUTPUT:
*
*/
import java.util.concurrent.*;
import javax.swing.*;
import java.awt.*;
import net.mindview.util.*;
public class BoxLayout1 extends JFrame {
public BoxLayout1() {
//Set up the content pane.
addComponentsToPane(getContentPane());
}
public static void addComponentsToPane(Container pane) {
pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS));
JButton b;
for (int i = 0; i < 4; i++) {
b = new JButton("Button " + i);
b.setAlignmentX(Component.LEFT_ALIGNMENT);
pane.add(b);
}
b = new JButton("Long-Named Button 4");
b.setAlignmentX(Component.RIGHT_ALIGNMENT);
pane.add(b);
b = new JButton("5");
b.setAlignmentX(Component.RIGHT_ALIGNMENT);
pane.add(b);
}
public static void main(String[] args) {
SwingConsole.run(new BoxLayout1(), 300, 300);
}
}