There are 3 problems found by editing/running this program:
Problem #1: if List() is used, the list is not displayed.
Problem #2: if List(0, false) is used, same output as problem #1.
Problem #3: if List(2, false) is used, there are 3 items on top of
the list displayed. It should be only 2.
import java.awt.*;
public class choiceTest extends Frame {
public choiceTest() {
// Set up the color list
// List colorList = new List();
// List colorList = new List(0, false);
List colorList = new List(2, false);
colorList.addItem("Red");
colorList.addItem("Orange");
colorList.addItem("Yellow");
colorList.addItem("Green");
colorList.addItem("Blue");
colorList.addItem("Purple");
colorList.addItem("Black");
colorList.addItem("White");
System.out.println( colorList.getRows() );
Panel p = new Panel();
p.add(colorList);
add("Center", p);
}
public boolean handleEvent(Event e) {
if (e.id == Event.WINDOW_DESTROY)
System.exit(0);
return true;
}
public boolean action(Event e, Object arg) {
if (e.target instanceof List) {
System.out.println("List: " + arg);
}
return true;
}
public static void main(String args[]) {
Frame f = new choiceTest();
f.resize(300, 200);
f.show();
}
}
Problem #1: if List() is used, the list is not displayed.
Problem #2: if List(0, false) is used, same output as problem #1.
Problem #3: if List(2, false) is used, there are 3 items on top of
the list displayed. It should be only 2.
import java.awt.*;
public class choiceTest extends Frame {
public choiceTest() {
// Set up the color list
// List colorList = new List();
// List colorList = new List(0, false);
List colorList = new List(2, false);
colorList.addItem("Red");
colorList.addItem("Orange");
colorList.addItem("Yellow");
colorList.addItem("Green");
colorList.addItem("Blue");
colorList.addItem("Purple");
colorList.addItem("Black");
colorList.addItem("White");
System.out.println( colorList.getRows() );
Panel p = new Panel();
p.add(colorList);
add("Center", p);
}
public boolean handleEvent(Event e) {
if (e.id == Event.WINDOW_DESTROY)
System.exit(0);
return true;
}
public boolean action(Event e, Object arg) {
if (e.target instanceof List) {
System.out.println("List: " + arg);
}
return true;
}
public static void main(String args[]) {
Frame f = new choiceTest();
f.resize(300, 200);
f.show();
}
}