Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4014113

List() and List(nros, false) do not work as expected

    Details

    • Subcomponent:
    • Resolved In Build:
      1.1
    • CPU:
      sparc
    • OS:
      solaris_2.4
    • Verification:
      Not verified

      Description

      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();
          }
      }

        Attachments

          Activity

            People

            • Assignee:
              gsaab Georges Saab
              Reporter:
              tbarbaro Tracy Barbaro (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: