My last patches made the combobox unusable. The reason for this is that
the exact same event that should open the popup, now also immediately
closes the popup via the auto-closer. This is avoided by performing the
autocloser-registration after the current event (the one that opens the
popup) has been completely handled. This is achieved by simply putting
the registration code on the event queue.

2006-02-24  Roman Kennke  <[EMAIL PROTECTED]>

        * javax/swing/plaf/basic/BasicComboPopup.java
        (show): Register the popup with the autocloser after it has been
        opened completely, by putting the registration on the eventqueue.

/Roman
Index: javax/swing/plaf/basic/BasicComboPopup.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicComboPopup.java,v
retrieving revision 1.13
diff -u -r1.13 BasicComboPopup.java
--- javax/swing/plaf/basic/BasicComboPopup.java	24 Feb 2006 12:01:32 -0000	1.13
+++ javax/swing/plaf/basic/BasicComboPopup.java	24 Feb 2006 16:41:45 -0000
@@ -194,13 +194,23 @@
     if (selectedIndex > comboBox.getMaximumRowCount())
       scrollbar.setValue(getPopupHeightForRowCount(selectedIndex));
 
-    // Register this popup to be autoclosed when user clicks outside the
-    // popup.
-    BasicLookAndFeel laf = (BasicLookAndFeel) UIManager.getLookAndFeel();
-    laf.registerForAutoClose(this);
+    // We put the autoclose-registration inside an InvocationEvent, so that
+    // the same event that triggered this show() call won't hide the popup
+    // immediately.
+    SwingUtilities.invokeLater
+    (new Runnable()
+     {
+       public void run()
+       {
+         // Register this popup to be autoclosed when user clicks outside the
+         // popup.
+         BasicLookAndFeel laf = (BasicLookAndFeel) UIManager.getLookAndFeel();
+         laf.registerForAutoClose(BasicComboPopup.this);
+       }});
 
     // location specified is relative to comboBox
     super.show(comboBox, 0, cbBounds.height);
+
   }
 
   /**

Reply via email to