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

No ItemEvent nor ActionEvent fired on first UNSELECT in JComboBox

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.2.1, 1.2.2
    • client-libs
    • beta
    • generic, x86, sparc
    • generic, solaris_2.6, windows_98, windows_nt



      Name: vi73552 Date: 04/29/99


      JComboBox has a few items (strings)
      and registered ChangeListener and ActionListener,
      inside which print statement is coded .

      Now when this combo box is shown for the first time, it has the
      first item selected. Click on the combo to get popup with choices
      The first item is highlighted - correct.
      Move your mouse over first item, hold CONTROL key and click the item -
      it becomes unselected - the selection in combobox is empty - correct.
      What is incorrect is that no ItemEvent with "USELECTED" state change
      nor ActionEvent was generated. Now select an item and try to repeat
      the scenario unselecting it using CNTRL + mouseClick.
      Both ItemEvent and ActionEvent are generated - but
      what happened to the initial ones?????


      import javax.swing.*;
      import java.awt.event.*;
      import javax.swing.border.*;
      import java.awt.*;
      public class a
      {

      public static void main(String args[])
          {
            JComboBox combo = new JComboBox(new String [] {"task 1","task 2", "task3","task 4","task "});

            combo.addActionListener(
              new ActionListener()
              {
                public void actionPerformed(ActionEvent e)
                  {
                    System.out.println("Action event");
                  }
              });

            combo.addItemListener(
              new ItemListener()
              {
                public void itemStateChanged(ItemEvent e)
                  {
                    System.out.println("Item state changed");
                  }
              });

              JFrame f = new JFrame();
              f.getContentPane().add(combo);
              f.pack();
              f.setVisible(true);
         }
      }
      (Review ID: 57636)
      ======================================================================

            mdavidsosunw Mark Davidson (Inactive)
            vasya Vassili Igouchkine (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: