forked from patniemeyer/learningjava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBorder2.java
More file actions
34 lines (31 loc) · 886 Bytes
/
Copy pathBorder2.java
File metadata and controls
34 lines (31 loc) · 886 Bytes
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
//file: Border2.java
import java.awt.*;
import javax.swing.*;
public class Border2 extends JPanel {
public Border2() {
setLayout(new BorderLayout( ));
JPanel p = new JPanel();
p.add(new JButton("North"));
add(p, BorderLayout.NORTH);
p = new JPanel();
p.add(new JButton("South"));
add(p, BorderLayout.SOUTH);
p = new JPanel();
p.add(new JButton("East"));
add(p, BorderLayout.EAST);
p = new JPanel();
p.add(new JButton("West"));
add(p, BorderLayout.WEST);
p = new JPanel();
p.add(new JButton("Center"));
add(p, BorderLayout.CENTER);
}
public static void main(String[] args) {
JFrame frame = new JFrame("Border2");
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
frame.setSize(225, 150);
frame.setLocation(200, 200);
frame.setContentPane(new Border2());
frame.setVisible(true);
}
}