1import java.applet.Applet;
2import java.awt.*;
3
4public
5class AllComponentsApplet extends FrameApplet {
6
7 public
8 void init() {
9 width = getIntParameter("frameWidth", width );
10 height = getIntParameter("frameHeight",height);
11
12 f = new AllComponentsFrame("All Components Demo");
13 f.setSize(width,height);
14 }
15}
16
17class AllComponentsFrame extends Frame {
18
19
20 MenuBar menubar;
21
22
23 Menu file, help;
24
25
26 Button okay, cancel;
27
28
29 List list;
30
31
32 Choice choice;
33
34
35 CheckboxGroup checkbox_group;
36
37
38 Checkbox[] checkboxes;
39
40
41 TextField textfield;
42
43
44 TextArea textarea;
45
46
47 Canvas canvas;
48
49
50 FileDialog file_dialog;
51
52
53 Panel panel1, panel2;
54
55
56 Panel buttonpanel;
57
58 public
59 AllComponentsFrame(String title) {
60 super(title);
61
62
63
64
65 menubar = new MenuBar();
66 setMenuBar(menubar);
67
68 file = new Menu("Datei");
69 file.add(new MenuItem("Oeffnen"));
70 file.add(new MenuItem("Ende"));
71 menubar.add(file);
72
73 help = new Menu("Hilfe");
74 help.add(new MenuItem("Ueber"));
75 menubar.add(help);
76
77
78 menubar.setHelpMenu(help);
79
80
81
82
83 okay = new Button("O.K.");
84 cancel = new Button("Abbruch");
85
86
87
88
89 choice = new Choice();
90 choice.add("rot");
91 choice.add("gruen");
92 choice.add("blau");
93
94
95
96
97 checkbox_group = new CheckboxGroup();
98 checkboxes = new Checkbox[3];
99 checkboxes[0] = new Checkbox("gross", checkbox_group, false);
100 checkboxes[1] = new Checkbox("mittel", checkbox_group, true);
101 checkboxes[2] = new Checkbox("klein", checkbox_group, false);
102
103
104
105
106 list = new List(4, true);
107 list.add("Java");
108 list.add("C");
109 list.add("C++");
110 list.add("Smalltalk");
111 list.add("Lisp");
112 list.add("Fortran");
113 list.add("Cobol");
114
115
116
117
118 textfield = new TextField(15);
119
120 textarea = new TextArea("", 6, 40, TextArea.SCROLLBARS_VERTICAL_ONLY);
121 textarea.setEditable(false);
122
123
124 canvas = new Canvas();
125 canvas.setSize(200,100);
126
127
128 file_dialog = new FileDialog(this, "Datei lesen", FileDialog.LOAD);
129
130
131 panel1 = new Panel();
132 panel2 = new Panel();
133 buttonpanel = new Panel();
134
135
136
137
138
139 panel1.setLayout(new FlowLayout());
140
141 panel1.add(new Label("Name:"));
142 panel1.add(textfield);
143 panel1.add(new Label("Farbe:"));
144 panel1.add(choice);
145
146 for (int i=0;
147 i < checkboxes.length;
148 ++i) {
149 panel1.add(checkboxes[i]);
150 }
151
152 panel1.add(new Label("Sprachen:"));
153 panel1.add(list);
154
155
156
157 panel2.setLayout(new FlowLayout());
158
159 panel2.add(new Label("Nachricht"));
160 panel2.add(textarea);
161
162 panel2.add(new Label("Grafik"));
163 panel2.add(canvas);
164
165
166 buttonpanel.setLayout(new FlowLayout());
167 buttonpanel.add(okay);
168 buttonpanel.add(cancel);
169
170
171 setLayout(new GridLayout(3,1));
172
173 add(panel1);
174 add(panel2);
175 add(buttonpanel);
176
177 }
178}
179
180