JDK-6477341 : Regression: JComboBox has wrong width under WindowsXP L&F
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2006-10-02
  • Updated: 2010-05-08
  • Resolved: 2006-10-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.
Other JDK 6
5.0u11Resolved 6 b103Fixed
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.6.0-rc"
java(TM) SE Runtime Environment (build 1.6.0-rc-b99)
Java HotSpot(TM) Client VM (build 1.6.0-rc-b99, mixed mode, sharing)

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

A DESCRIPTION OF THE PROBLEM :
The width of a JComboBox is too narrow under WindowsXP Look&Feel. This results in truncated text (trailing characters are replaced by "...") when the widest combo box item is displayed.



REGRESSION.  Last worked in version mustang

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the test case and take a look at the text displayed in the JComboBox.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The text "mm" should be displayed on the JComboBox
ACTUAL -
The text "..." is displayed.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.awt.*;

/**
 * Test to visualize a bug in JDK6-b99 on Windows XP
 * Displays a JComboBox and a JLabel in a JFrame. The label only has the purpose of making sure that the combo
 * box only occupies as much space as it requires.
 * On JDK6-b99 you will see that the combo box will display "..." instead of "mm".
 */
public class ComboBoxTest {

  public static void main(String[] args) {
    // set windows xp look and feel (on Windows XP platform)
    try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception ex) {
      ex.printStackTrace();
    }
    // create and display frame
    JFrame jFrame = new JFrame("JComboBox Test");
    jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    jFrame.setLayout(new BorderLayout());
    jFrame.add(new JComboBox(new Object[]{"mm", "cm"}), BorderLayout.WEST);
    jFrame.add(new JLabel("<------fill----->"), BorderLayout.CENTER);
    jFrame.pack();
    jFrame.setLocationRelativeTo(null);
    jFrame.setVisible(true);
  }
}
---------- END SOURCE ----------

Release Regression From : 1.5
The above release value was the last known release where this 
bug was not reproducible. Since then there has been a regression.
http://forums.java.net/jive/thread.jspa?threadID=18752&tstart=0

Comments
EVALUATION This was the result of a merge error. I am submitting a new webrev to address it. Because of concerns of a possible infinite loop with calling super.getPreferredSize() from getMinimumSize() if it is subclassed I am leaving that change from preferred to minimum out. This means that 6340871 is no longer fixed.
13-10-2006

EVALUATION This was supposed to have been fixed by 6439971. Unfortunately, the code doesn't seem to have made it into the code base. Will apply it now.
13-10-2006

EVALUATION DELETED
12-10-2006

EVALUATION DELETED
11-10-2006

EVALUATION Note that this code has been changed once more since the bug fix mentioned above. But I have confirmed that we're still too small to render the largest item. This needs to be fixed.
04-10-2006

EVALUATION ###@###.### tested it with promted builds. The first build the bug is reproduced on is mustang-b88. The first swing nighlty build it was reporoduced on is 2006-05-26.mustang. This regression was introduced by the fix for 6382711 [JComboBox incorrectly rendered with alternate WinXP theme]. I think this bug was caused by this change: WindowsComboBoxUI.java public void paintCurrentValue(Graphics g, Rectangle bounds, boolean hasFocus) { ! bounds.x += 2; ! bounds.y += 2; ! bounds.width -= 3; ! bounds.height -= 4; ---- ! bounds.x += 3; ! bounds.y += 3; ! bounds.width -= 5; ! bounds.height -= 6; --------------- New bounds.width is smaller than the old one by 2 thus the text is replaced by "..."
02-10-2006