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

BasicComboBoxUI item state changing behaivior has incompatibly changed

    Details

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

      Description



      Name: nkR10003 Date: 10/25/2000


      ItemHandler class is being used by previous versions of
      BasicComboBoxUI to trace "item select" actions.
      The functionality of this class (ItemHandler) has been moved into
      ListDataHandler and so incompatibly changed.
      Also MetalComboBoxUI inherits this technique to trace selection actions.
      The same problem with ItemHandler appears in BasicComboPopup class.

      Please send out CCC request.

      Example below demonstrates this problem:
      ------------------example--------------------
      //test.java
      import javax.swing.*;
      import java.awt.event.*;
      import javax.swing.plaf.metal.MetalComboBoxUI;
      import javax.swing.event.*;

      public class test {
          public static void main(String[] args) {
              String[] data = {"one", "two", "three", "four", "five"};
              JComboBox comboBox = new JComboBox(data);
              MyComboBoxUI c = new MyComboBoxUI();
              comboBox.setUI(c);

              c.clearItemChangedFlag();
              comboBox.setSelectedItem(data[1]);

              //test that any listener was invoked
              if (!c.isItemChangedFlag()) {
                  System.out.println("Item state listener does not "
                          + "trace item selection");
                  System.out.println("============");
                  System.out.println("Test Failed");
                  System.exit(1);
              }

              System.out.println("Test passed OK");
              System.exit(0);
          }
      }

      class MyComboBoxUI extends MetalComboBoxUI {
          private boolean itemChangedFlag = false;
          
          protected ItemListener createItemListener() {
              return new MyItemHandler();
          }

          public boolean isItemChangedFlag() {
              return itemChangedFlag;
          }

          public void clearItemChangedFlag() {
              itemChangedFlag = false;
          }

          public class MyItemHandler extends MetalComboBoxUI.ItemHandler {
              public void itemStateChanged(ItemEvent e) {
                  super.itemStateChanged(e);
                  itemChangedFlag = true;
                  System.out.println(4);
              }
          }
      }
      ----------------output:----------------------
      Item state listener does not trace item selection
      ============
      Test Failed
      ---------------------------------------------
      ======================================================================

        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: