-
Bug
-
Resolution: Fixed
-
P3
-
1.4.2, 5.0
-
b43
-
x86
-
windows_xp
Name: gm110360 Date: 12/10/2003
FULL PRODUCT VERSION :
java version "1.4.2_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06)
Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
EXTRA RELEVANT SYSTEM CONFIGURATION :
Using XP desktop style
A DESCRIPTION OF THE PROBLEM :
Not enough width for text box in JComboBox with XP desktop style. With native code and XP style, there is white space to the left of the text in a drop-down combo box. With Java 1.4.2 (and 1.5) there is no space, and if using the XP standard font (Tahoma 11pt) the space may be so small that only an ellipsis (...) shows.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
The following code shows the problem. It shows two JComboBox components, the left one with the default font (which is incorrectly MS Sans Serif for me) and the right one with correct XP system font (Tahoma). Neither has space to the left of the text, and the Tahoma one only shows an ellipsis for the text.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class bug4966585 extends JComboBox {
bug4966585() {
// Combo box with short entries
addItem("ms");
addItem("s");
addItem("m");
addItem("h");
// Workaround
// setPreferredSize(new Dimension(getPreferredSize().width + 1,
// getPreferredSize().height));
}
void PrintInfo(int i) {
// Print out font info and control sizes
Font f = getFont();
FontMetrics fm = getFontMetrics(f);
System.out.println("ComboBox " + i +":");
System.out.println("Font: " + f.toString());
System.out.println("FontMetrics: " + fm.toString());
System.out.println("Combo width: " + getSize().width);
System.out.println("String width: " + fm.stringWidth((String)getItemAt(1)));
}
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch(Exception e) {
System.out.println(e);
}
JFrame f = new JFrame("XPComboBox test");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = f.getContentPane();
c.setLayout(new FlowLayout());
// Use default font (not XP standard) for 1st combo
bug4966585 cb1 = new bug4966585();
c.add(cb1);
// Use standard XP font for 2nd combo
bug4966585 cb2 = new bug4966585();
cb2.setFont(new Font("Tahoma", Font.PLAIN, cb1.getFont().getSize()));
c.add(cb2);
f.pack();
f.setVisible(true);
// Print out font info and control sizes
cb1.PrintInfo(1);
cb2.PrintInfo(2);
}
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The JComboBox with Tahoma font should not just show an ellipsis, and both combo boxes should have some whitespace to the left of the text (as in the native XP combo box).
ACTUAL -
The right hand combo box just shows an ellipsis.
Neither combo box has white space to the left of the text.
REPRODUCIBILITY :
This bug can be reproduced always.
(Incident Review ID: 230009)
======================================================================
- duplicates
-
JDK-4978939 REGRESSION: JComboBox default width is to narrow
- Closed
-
JDK-4982384 REGRESSION:"Background" text in ComboBox is not entirely displayed
- Closed
-
JDK-6200348 REGRESSION: JComboBox cut the items display on XP L&F
- Closed
-
JDK-4991586 JComboBox minimumSize is computed incorrectly
- Closed
- relates to
-
JDK-6340871 REGRESSION: ComboBox height changes on Splitpane resize with Gridbag Layout
- Resolved
-
JDK-4773496 Win L&F: not enough padding in JComboBox
- Resolved
-
JDK-4937812 PIT: XP L&F: Gap betwn JCombo selection rectangle & border rectangle is more
- Resolved
-
JDK-5032174 Combobox's drop down Button is bigger than the native windows Combobox
- Closed