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

Inconsistency in JComboBox events make it impractical for more serious use.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • None
    • 5.0
    • client-libs
    • None

      JComboBox will issue two different actionEvents, comboBoxChanged and comboBoxEdited.
      I postulate that these are issued in inconsistent ways which make JComboBox
      unusable in any but the most trivial applications
      It is especially hard to make keyboard traversal and mouse selection to
      work consistently.
      Hence the P3.

      There are three ways one can affect change in selectionin a combo box:
      - keyboard travewrsal. Issue an arrow key, navigate with arrow keys, issue enter.
        This generates the sequence of events comboBoxChanged*N - comboBoxEdited.
        With a comboBoxChanged for each navigation with arrow.
      - choose by mouse via the popup.
        This generates a single comboBoxChanged event.
      - edit text directly and press Enter.
        This generates a comboBoxChanged followed by comboBoxEdited.


      If one tries to be discerning by checking for comboBoxChanged or comboBoxEdited
      it's clear that handling just one of them is insufficient. As for
      these being implementation-specific see 4808758 (RFE: comboBoxChanged and
      comboBoxEdited not documented

      If one handles actionPerformed indiscriminantly then there's plenty of
      opportunity for redundancy.
      Why is redundancy bad?
      There are various cases where some reasonably expensive operation happens when
      a selection is chosen:
      - The example in java tutorials causes a different picture to be drawn.
        Suppose the picture comes over the web.
      - My own case ... I have a debugger attach dialog in SunStudio with a filter.
        When the filter value changes I issue 'ps' (potentially ona remote machine)
        and redisplay the filtered items.
      - In the NetBeans IDE, go to Tools->Options->Fonts&Colors.
        Pick the Syntax Tab. Now alter Language using arrow keys.
        On each arrow motion there is a significant lag as the selected stuff gets
        fed back to the user.

      As if this wasn't enough ... in SunStudio's attach dialog we override
      the combobox to be a MostRecentlyUsed list. But because arrow navigation
      attempts to enter items, in practice (like in SunStudio12) these two interact and
      arrow navigation ends up swaping the top-two items as opposed to actually
      navigating.

            Unassigned Unassigned
            isoleima Ivan Soleimanipour (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: