The Java Program: BorderLayoutDemo.java
1 // BorderLayoutDemo.java -- Applet using BorderLayout, adapted from Naughton
2
3 /*
4 <applet code="BorderLayoutDemo.class" width=500 height=200></applet>
5 */
6
7 import java.applet.Applet;
8 import java.awt.*;
9 import java.util.*;
10
11 public class BorderLayoutDemo extends Applet {
12
13 public void init() {
14 setLayout (new BorderLayout());
15
16 Dimension window = size();
17 int width = window.width;
18 int height = window.height;
19
20 add ("North", new Button("This is across the top"));
21 add ("South", new Label("The footer message might go here"));
22 add ("East", new Button("Left"));
23 add ("West", new Button("Right"));
24
25 String msg = "The reasonable man adapts " +
26 "himself to the world;\n" +
27 "the unreasonable one persists in " +
28 "trying to adapt the world to himself.\n" +
29 "Therefore all progress depends " +
30 "on the unreasonable man.\n\n" +
31 " - George Bernard Shaw\n\n";
32
33 add ("Center", new TextArea(msg));
34 }
35 }