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

BasicComboPopup list selection behaivior has been incompatibly changed

    Details

    • Subcomponent:
    • Resolved In Build:
      beta
    • CPU:
      sparc
    • OS:
      solaris_2.6

      Description



      Name: nkR10003 Date: 11/20/2000


      JavaDoc for BasicComboPopup.ListSelectionHandler class states:
      "This listener watches for changes in the list's selection and reports
      them to the combo box." This does not work from JDK1.4 version.

      Please send out CCC request.

      Example below demonstrates this problem:
      ------------------example--------------------
      import javax.swing.*;
      import javax.swing.plaf.basic.*;

      public class jdk_bug24_test {
          public static void main(String[] args) {
              JFrame frame = new JFrame("Test");
              frame.setSize(100,50);
              String[] data = {"one", "two", "three", "four", "five"};
              JComboBox comboBox = new JComboBox(data);
              //setUI -> installUI -> installXXXListeners
              comboBox.setUI(new StubComboBoxUI());
              for (int i=0; i<data.length; i++) {
                  ((StubComboBoxUI)comboBox.getUI()).
                          stubSetListSelection(i);
                  if (comboBox.getSelectedIndex() != i) {
                      System.out.println("list selection : " + i);
                      System.out.println("combo selection: "
                              + comboBox.getSelectedIndex());
                      System.out.println("Test failed");
                      System.exit(1);
                  }
              }
              
              System.out.println("Test passed: OK");
              System.exit(0);
              
          }
      }

      class StubComboBoxUI extends BasicComboBoxUI {
          StubComboBoxUI() {
              super();
          }
          
          public void stubSetListSelection(int index) {
              popup.getList().setSelectedIndex(index);
          }
      }
      ----------------output:----------------------
      java version "1.4.0beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0beta-b40)
      Java HotSpot(TM) Client VM (build 1.4beta-B40, mixed mode)
      -------------------------------
      list selection : 1
      combo selection: 0
      Test failed
      =============================================
      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
      Java HotSpot(TM) Client VM (build 1.3.0-C, interpreted mode)
      --------------------------------
      Test passed: OK
      ---------------------------------------------
      ======================================================================

        Attachments

          Activity

            People

            • Assignee:
              mdavidsosunw Mark Davidson (Inactive)
              Reporter:
              knasunw Kna Kna (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: