1import java.awt.BorderLayout;
2
3import javax.swing.JApplet;
4import javax.swing.JButton;
5import javax.swing.JFrame;
6
7public
8class BorderLayoutApplet extends JApplet {
9 JFrame f;
10 public void init() {
11 f = new MyFrame();
12 f.setVisible(true);
13 }
14}
15
16class MyFrame extends JFrame {
17 public MyFrame() {
18 setTitle("Border Layout Demo");
19 setSize(300, 300);
20 setLayout(new BorderLayout());
21 add(new JButton("yellow"), BorderLayout.NORTH);
22 add(new JButton("magenta"), BorderLayout.NORTH);
23 add(new JButton("red"), BorderLayout.SOUTH);
24 add(new JButton("green"), BorderLayout.WEST);
25 add(new JButton("blue"), BorderLayout.EAST);
26 add(new JButton("cyan"), BorderLayout.CENTER);
27 pack();
28 }
29}