This patch fixes the last outstanding (AFAICT) layout issue in the JComboBox: 1. the popup was slightly too wide, which is caused by the layout not respecting the popup's insets. 2. empty comboboxes have a default height of 100 in Sun's impl. I fixed the BasicComboPopup to also do this.
2006-03-18 Roman Kennke <[EMAIL PROTECTED]>
* javax/swing/plaf/basic/BasicComboPopup.java
(show): Substract insets from scroller width.
(getPopupHeightForRowCount): If height==0, return a default of
100
instead for empty ComboBoxes.
/Roman
--
“Improvement makes straight roads, but the crooked roads, without
Improvement, are roads of Genius.” - William Blake
Index: javax/swing/plaf/basic/BasicComboPopup.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicComboPopup.java,v
retrieving revision 1.15
diff -u -r1.15 BasicComboPopup.java
--- javax/swing/plaf/basic/BasicComboPopup.java 17 Mar 2006 15:37:01 -0000 1.15
+++ javax/swing/plaf/basic/BasicComboPopup.java 18 Mar 2006 13:48:23 -0000
@@ -41,6 +41,7 @@
import java.awt.Color;
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;
@@ -185,6 +186,8 @@
{
Dimension size = comboBox.getSize();
size.height = getPopupHeightForRowCount(comboBox.getMaximumRowCount());
+ Insets i = getInsets();
+ size.width -= i.left + i.right;
Rectangle bounds = computePopupBounds(0, comboBox.getBounds().height,
size.width, size.height);
@@ -197,7 +200,8 @@
list.ensureIndexIsVisible(list.getSelectedIndex());
setLightWeightPopupEnabled(comboBox.isLightWeightPopupEnabled());
- show(comboBox, bounds.x, bounds.y); }
+ show(comboBox, bounds.x, bounds.y);
+ }
/**
* This method hides drop down list of items
@@ -710,7 +714,7 @@
totalHeight += dim.height;
}
- return totalHeight;
+ return totalHeight == 0 ? 100 : totalHeight;
}
/**
signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil
