JDK-6439971 : JComboBox width is too narrow on Windows XP L& F
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 5.0,6
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2006-06-16
  • Updated: 2010-04-02
  • Resolved: 2006-08-18
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6 b96Fixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.6.0-rc"
Java(TM) SE Runtime Environment (build 1.6.0-rc-b88)
Java HotSpot(TM) Client VM (build 1.6.0-rc-b88, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
  Bug # 4966585  exists in Mustang.  Text is cut off and replaced with "..." on JComboBoxes with the Win XP LnF.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the supplied test case

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Text should not be truncated and replaceed with "..."
ACTUAL -
Text is truncated and replaced with "..."

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.BorderLayout;

import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

/*
 * Created on 16-Jun-2006
 *
 */

public class ComboTest
{
	public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException
	{
		UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		JFrame f = new JFrame("Windows XP LnF - ComboBox Width Test");
		JComboBox cb = new JComboBox(new String [] {"Video + Audio", "Video only", "Audio only"});
		JPanel p = new JPanel();
		p.add(cb);
		f.getContentPane().add(p, BorderLayout.NORTH);
		f.getContentPane().add(new JLabel("The above combox is sized too narrow on Java 6 and cuts off the text of the first item.  Java 5 does not have the problem."), BorderLayout.SOUTH);
		f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		f.pack();
		f.setVisible(true);
	}

}

---------- END SOURCE ----------

Release Regression From : 5.0
The above release value was the last known release where this 
bug was not reproducible. Since then there has been a regression.

Release Regression From : 5.0
The above release value was the last known release where this 
bug was not reproducible. Since then there has been a regression.

Comments
EVALUATION This fix was lost during a code merge. Will re-apply under 6477341.
16-10-2006

EVALUATION The root cause of this is not the preferred size, but the insets. Both the insets of the editor and the paintable insets of the comobobox itself are off by a couple of pixels. The solution is to change the painted insets for noneditable comboboxes to be correct (widening them by 2px on each side). Secondly, the border on the editor is wrong, making the contents of the editor too small. The solution for this is to create a new UIDefaults property called ComboBox.editorBorder and use that for the editor's border. Fixing this CR should also fix: 6438050 and 6418233.
29-06-2006

EVALUATION This is likely just a bug in calculating the preferred size. I will test against the newest combobox fixes which may address the problem. If not it is likely the padding constants are still off by a pixel or two.
28-06-2006