-
Notifications
You must be signed in to change notification settings - Fork 0
/
Swing30.java
33 lines (26 loc) · 1.01 KB
/
Swing30.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
import javax.swing.*;
import java.awt.*;
public class Swing30 {
public static void main(String[] args) {
JFrame frame = new JFrame("Card Layout");
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setBounds(0,0,500,300);
Container c = frame.getContentPane();
BoxLayout boxLayout = new BoxLayout(c,BoxLayout.X_AXIS);
c.setLayout(boxLayout);
JButton button = new JButton("1");
JButton button2 = new JButton("2");
JButton button3 = new JButton("3");
JButton button4 = new JButton("4");
button.setAlignmentX(Component.LEFT_ALIGNMENT);
button2.setAlignmentX(Component.LEFT_ALIGNMENT);
button3.setAlignmentX(Component.LEFT_ALIGNMENT);
button4.setAlignmentX(Component.LEFT_ALIGNMENT);
c.add(button);
c.add(Box.createRigidArea(new Dimension(80,0)));
c.add(button2);
c.add(button3);
c.add(button4);
}
}