The Java Program: ChoiceDemo.java
1 // ChoiceDemo.java -- Illustate component "Choice"; adapted from Naughton
2
3 /*
4 * <applet code="ChoiceDemo.class" width=200 height=100></applet>
5 */
6
7 import java.awt.*;
8 import java.applet.*;
9
10 public class ChoiceDemo extends Applet {
11
12 public void init() {
13 setLayout(null);
14
15 Dimension d = this.size();
16 int width = d.width;
17 int height = d.height;
18
19
20 Choice os = new Choice();
21 os.addItem ("Windows 95");
22 os.addItem ("Solaris 2.x");
23 os.addItem ("MacOS 7.5");
24
25 Choice browser = new Choice();
26 browser.addItem ("Netscape 1.1");
27 browser.addItem ("Netscape 2.0");
28 browser.addItem ("Internet Explorer 2.0");
29 browser.addItem ("Internet Explorer 3.0");
30 browser.addItem ("Lynx 2.4");
31 browser.select ("Netscape 2.0");
32
33 add (os);
34 add (browser);
35
36 os.reshape (0, 0, width, height/2);
37 browser.reshape (0, height/2, width, height/2);
38 }
39 }