summaryrefslogtreecommitdiffstats
path: root/lib/example/Simple.java
diff options
context:
space:
mode:
Diffstat (limited to 'lib/example/Simple.java')
-rw-r--r--lib/example/Simple.java62
1 files changed, 62 insertions, 0 deletions
diff --git a/lib/example/Simple.java b/lib/example/Simple.java
new file mode 100644
index 0000000..3ff9fb9
--- /dev/null
+++ b/lib/example/Simple.java
@@ -0,0 +1,62 @@
1package example;
2
3
4
5import java.awt.*;
6import java.awt.event.*;
7import layout.TableLayout;
8
9
10
11public class Simple
12{
13
14
15
16 public static void main (String args[])
17 {
18 // Create a frame
19 Frame frame = new Frame("Example of TableLayout");
20 frame.setBounds (100, 100, 300, 300);
21
22 // Create a TableLayout for the frame
23 double border = 10;
24 double size[][] =
25 {{border, 0.10, 20, TableLayout.FILL, 20, 0.20, border}, // Columns
26 {border, 0.20, 20, TableLayout.FILL, 20, 0.20, border}}; // Rows
27
28 frame.setLayout (new TableLayout(size));
29
30 // Create some buttons
31 String label[] = {"Top", "Bottom", "Left", "Right", "Center", "Overlap"};
32 Button button[] = new Button[label.length];
33
34 for (int i = 0; i < label.length; i++)
35 button[i] = new Button(label[i]);
36
37 // Add buttons
38 frame.add (button[0], "1, 1, 5, 1"); // Top
39 frame.add (button[1], "1, 5, 5, 5"); // Bottom
40 frame.add (button[2], "1, 3 "); // Left
41 frame.add (button[3], "5, 3 "); // Right
42 frame.add (button[4], "3, 3, c, c"); // Center
43 frame.add (button[5], "3, 3, 3, 5"); // Overlap
44
45 // Allow user to close the window to terminate the program
46 frame.addWindowListener
47 (new WindowAdapter()
48 {
49 public void windowClosing (WindowEvent e)
50 {
51 System.exit (0);
52 }
53 }
54 );
55
56 // Show frame
57 frame.show();
58 }
59
60
61
62} \ No newline at end of file