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