classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] RFC: Fix for JComboBox drop down list


From: David Gilbert
Subject: [cp-patches] RFC: Fix for JComboBox drop down list
Date: Thu, 29 Sep 2005 14:51:43 +0000
User-agent: Mozilla Thunderbird 1.0.6 (X11/20050728)

This patch fixes a problem with the drop down list in a JComboBox where the list keeps getting wider and wider every time it is shown. It involves a small change to the JPopupMenu class, which I'm not familiar with, so I'm asking for comments before I commit this:

2005-09-29  David Gilbert  <address@hidden>

        * javax/swing/JPopupMenu.java
        (setVisible): use current size, not preferred size, when checking for
        screen edge,
        * javax/swing/plaf/basic/BasicComboPopup.java
        (show): include top and bottom insets in preferred size.

Regards.

Dave
Index: javax/swing/JPopupMenu.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/JPopupMenu.java,v
retrieving revision 1.25
diff -u -r1.25 JPopupMenu.java
--- javax/swing/JPopupMenu.java 28 Sep 2005 13:59:14 -0000      1.25
+++ javax/swing/JPopupMenu.java 29 Sep 2005 13:43:44 -0000
@@ -564,8 +564,7 @@
             Dimension screenSize = getToolkit().getScreenSize();
             
             boolean fit = true;
-            Dimension size = this.getPreferredSize();
-
+            Dimension size = this.getSize();
             if ((size.width > (rootContainer.getWidth() - popupLocation.x))
                 || (size.height > (rootContainer.getHeight() - 
popupLocation.y)))
               fit = false;
Index: javax/swing/plaf/basic/BasicComboPopup.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicComboPopup.java,v
retrieving revision 1.7
diff -u -r1.7 BasicComboPopup.java
--- javax/swing/plaf/basic/BasicComboPopup.java 2 Jul 2005 20:32:50 -0000       
1.7
+++ javax/swing/plaf/basic/BasicComboPopup.java 29 Sep 2005 13:43:45 -0000
@@ -40,6 +40,7 @@
 
 import java.awt.Component;
 import java.awt.Dimension;
+import java.awt.Insets;
 import java.awt.Point;
 import java.awt.Rectangle;
 import java.awt.event.ItemEvent;
@@ -179,7 +180,10 @@
     int popupHeight = getPopupHeightForRowCount(comboBox.getMaximumRowCount());
 
     list.setPreferredSize(new Dimension(cbBounds.width, popupHeight));
-    super.setPopupSize(cbBounds.width, popupHeight);
+    Insets insets1 = getInsets();
+    Insets insets2 = scroller.getInsets();
+    super.setPopupSize(cbBounds.width, popupHeight + insets1.top 
+            + insets1.bottom + insets2.top + insets2.bottom);
 
     // Highlight selected item in the combo box's drop down list
     if (comboBox.getSelectedIndex() != -1)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]