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

unix: List.select(-1) method invocation leads to unexpected result.

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 1.1.7, 1.3.0, 1.4.0, 1.4.1, 1.4.2
    • Fix Version/s: 5.0
    • Component/s: client-libs
    • Subcomponent:
    • Resolved In Build:
      tiger
    • CPU:
      x86, sparc, itanium
    • OS:
      generic, linux, solaris_7, solaris_8, windows_98
    • Verification:
      Verified

      Description



      Name: iaR10016 Date: 05/29/2000



      JDK version:
      java version "1.3.0beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0beta-b07)
      Java HotSpot(TM) Client VM (build 1.3.0beta-b04, mixed mode)

      Java 2 Platform SE v1.3 specification reads about the List.select(int) method:

      ...
      public void select(int index)
             Selects the item at the specified index in the scrolling list.
             Parameters:
                    index - the position of the item to select.
             See Also:
                    getSelectedItem(), deselect(int), isIndexSelected(int)...
      ...

      Specification does not stay that select(-1) must lead to selecting item with maximum index.

      In Linux JDK 1.3 and Solaris JDK 1.3 calling List.select(-1) leads to selecting item with
      maximum index. Note that after calling List.select with argument greater then maximum list index
      selected item index is not changed.

      In Window95 JDK 1.3 calling List.select(-1) leads to the selected item unselecting.

      JCK 1.3 runtime test api/java_awt/interactive/ListTests.html#ListTest0005 fails due to this bug.

      The following test example creates frame with List component. By clicking button "Select Item -1"
      you can call method List.select(-1). After this button clicking item3 becomes selected.

      ---------------------------------- test.java -------------------------------------------------------

      import java.awt.*;
      import java.awt.event.*;

      public class test extends Frame implements ActionListener
      {
          List aList;
          void init() {
              aList= new List();
              aList.add("Test item1");
              aList.add("Test item2");
              aList.add("Test item3");
              Button aButton = new Button("Select Item -1");
              aButton.addActionListener(this);
              Panel aPanel = new Panel();
              aPanel.add(aList);
              aPanel.add(aButton);
              setSize(200,200);
              add(aPanel);
          }

          public static void main(String [] argv)
          {
              test t = new test();
              t.init();
              t.setVisible(true);
          }

          public void actionPerformed(ActionEvent e) {
              System.out.println("Selected item is " + aList.getSelectedIndex());
              aList.select(-1);
              System.out.println("After select(-1) selected item is " + aList.getSelectedIndex());
          }
      }

      ======================================================================

      Name: icR10030 Date: 01/15/2002


      The other testcase ListTest0006 fails due to the bug too.

      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                kdmsunw Kdm Kdm (Inactive)
                Reporter:
                irasunw Ira Ira (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: