Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4618607

RFE: Popups for narrow JComboBox are too narrow

XMLWordPrintable

    • generic, x86
    • generic, linux, windows_95, windows_98, windows_2000, windows_xp

      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)
      ======================================================================

            Unassigned Unassigned
            ddressersunw Daniel Dresser (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: