JDK-4618607 : RFE: Popups for narrow JComboBox are too narrow
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version:
    1.1.5,1.2.0,1.3.1,1.4.0,1.4.1,1.4.2,6 1.1.5,1.2.0,1.3.1,1.4.0,1.4.1,1.4.2,6
  • Priority: P5
  • Status: Closed
  • Resolution: Won't Fix
  • OS:
    generic,linux,windows_95,windows_98,windows_2000,windows_xp generic,linux,windows_95,windows_98,windows_2000,windows_xp
  • CPU: generic,x86
  • Submitted: 2002-01-02
  • Updated: 2019-12-17
  • Resolved: 2019-12-17
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Description
Name: ddT132432			Date: 01/02/2002


FULL PRODUCT VERSION :
I tried all versions, including J2SE 1.4.0 beta 3

FULL OPERATING SYSTEM VERSION : any Windows


ADDITIONAL OPERATING SYSTEMS : I have not checked


A DESCRIPTION OF THE PROBLEM :
Sometimes it is necessary for a JComboBox to be less wide
than its preferred width. The current UI code limits the
width of the popup list for the JComboBox to the width of
the combo box, rather than the preferred width. Because of
this, many of the list items cannot be distinguished from
each other.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Build a narrow JComboBox
2. Click on it an look at the popup

EXPECTED VERSUS ACTUAL BEHAVIOR :
I would like to see the full data in the popup, not a
clipped version of the data.

This bug can be reproduced always.

---------- BEGIN SOURCE ----------
The show() method of BasicComboPopup contains the following
code:

Dimension popupSize = comboBox.getSize();
popupSize.setSize( popupSize.width,
getPopupHeightForRowCount( comboBox.getMaximumRowCount() )
);

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

CUSTOMER WORKAROUND :
This code, in BasicComboPopup.show(), fixes the problem:

Dimension popupSize = comboBox.getSize();
Dimension prefSize = comboBox.getPreferredSize(); // mod
popupSize.setSize(
           prefSize.width > popupSize.width // mod
          ? prefSize.width : popupSize.width // mod
           , getPopupHeightForRowCount(comboBox.getMaximumRowCount() ) );


I was able to deploy this fix using an elaborate patch
involving subclassing WindowsComboBoxUI.
(Review ID: 137845) 
======================================================================

Comments
EVALUATION Contribution forum : https://jdk-collaboration.dev.java.net/servlets/ProjectForumMessageView?forumID=1463&messageID=14248
13-07-2006

EVALUATION See eval of 4880218, which has been closed as a duplicate, for idea.
19-09-2005