summaryrefslogtreecommitdiffstats
path: root/libjava/classpath/javax/swing/plaf/basic/BasicComboBoxRenderer.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/javax/swing/plaf/basic/BasicComboBoxRenderer.java')
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicComboBoxRenderer.java16
1 files changed, 14 insertions, 2 deletions
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicComboBoxRenderer.java b/libjava/classpath/javax/swing/plaf/basic/BasicComboBoxRenderer.java
index 48195ff293b..3c8d1e8c589 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicComboBoxRenderer.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicComboBoxRenderer.java
@@ -75,12 +75,24 @@ public class BasicComboBoxRenderer
/**
* Returns preferredSize of the renderer
- *
+ *
* @return preferredSize of the renderer
*/
public Dimension getPreferredSize()
{
- return super.getPreferredSize();
+ if (this.getText() != null && ! this.getText().equals(""))
+ return super.getPreferredSize();
+ else
+ {
+ // If the combo box option's text is empty or null, it won't size
+ // properly (ie, it'll be way too short)... so we throw in a dummy
+ // space to trick the superclass's sizing methods.
+ String oldText = this.getText();
+ this.setText(" ");
+ Dimension d = super.getPreferredSize();
+ this.setText(oldText);
+ return d;
+ }
}
/**
OpenPOWER on IntegriCloud