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

JComboBox's ItemListeners are not notified when a the combo-box is assigned a different model

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 6u16
    • client-libs

      When a JComboBox has some ItemListeners registered, it should notify them whenever an item is selected or deselected. But the current implementation does not notify the listeners if a different item is selected as a result of changing the JComboBox's model.

      This bug is 100% reproducible both with JDK 1.5.0_21 and with JDK 6u16.

      I have created a simple application that does this:
      1) Creates a combo box model containing items: "Monday", "Tuesday", "Wednesday"
      2) Creates a second combo box model containing items "Alpha", "Beta", "Gamma"
      3) Creates a combo-box with the first model passed as the initial model.
      4) Selects item "Tuesday".
      5) Selects item "Wednesday".
      6) Switches the combo-box's model to the second model ("Alpha", "Beta", "Gamma").
      7) Selects item "Beta".
      8) Selects item "Gamma".
      The application also writes a short note to the standard output whenever the listener's ItemListener is notified about the selection change.

      (See the attachment for the source code of the simple application.)

      Expected behaviour:
        When the second model is assigned to the combo-box, the combo-box should notify all registered listeners about change of selected item.

      Actual behaiour:
        The listeners are not notified.

            dnguyen Damon Nguyen
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: