JDK-4249732 : JComboBox (Windows L&F) does not resemble native Windows combo
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.2.2
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 1999-06-25
  • Updated: 2001-07-25
  • Resolved: 2001-07-25
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 Availabitlity Release.

To download the current JDK release, click here.
Other
1.4.0 beta2Fixed
Description

Name: skT88420			Date: 06/25/99


JComboBox displaying a tree does not look like native
Windows combobox (displaying a tree).

1. JComboBox highlights entire row in the dropdown menu
   while selecting. (Native combo only highlights extent of
   "row content").

2. Native combo displays a "focus border" around the text
   of the selected value in the dropdown menu. JComboBox
   does not.

3. Native combo makes an image in the selected row darker
   while it is highlighted. JComboBox does not.


JComboBox example: SwingSet demo, "ComboBox" tab,
                   lower right combobox (with the "swing" tree).

Native Windows example: Start menu, "Find", "Files or Folders",
the "Look in:" combobox.


I am using JDK 1.2.2rc1 on Windows 98.

Please, I want the "Windows L&F" in Swing to be as close to
the native look and feel as possible.
Preferably *identical*
(Review ID: 84846) 
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: merlin merlin-beta2 FIXED IN: merlin-beta2 INTEGRATED IN: merlin-beta2
2004-06-14

WORK AROUND Name: skT88420 Date: 06/25/99 use MFC ? ======================================================================
2004-06-11

EVALUATION The user brings up some valid details that are left out in the Windows LAF implementation of the JComboBox. To clarify the points: 1. The native Windows implementation will only highlight the text only rather than the entire line like the Swing implementation. 2. When an item is selected from the drop down list in an editable combo box, the selected item is marked as selected in the combo box editor. 3. I'm not too sure about this point. Both of my implementations appear to be identical. I'm using Desert as my Windows scheme and the colors for native and Swing appear to be consistent. We will fix this for the next major release of the JDK. mark.davidson@Eng 2000-04-27 Name: pzR10082 Date: 07/05/2001 Swing does not automatically support displaying trees in JComboBox. This is done by custom client code which, apart from other things, provides a cell renderer used to display tree nodes inside combo box. This is the renderer that defines how exactly these tree nodes look. There's no such thing in Swing as "JComboBox displaying a tree". In case of SwingSet, a special class, TreeCombo, was used for displaying tree inside the combobox. It defined a renderer, ListEntryRenderer, which was responsible for the problem described in this report. However, SwingSet seems no longer supported. ###@###.### 2001-07-03 ====================================================================== Name: pzR10082 Date: 07/17/2001 Problem described under No.2 should nevertheless be fixed: in an editable combo, when an item is choosen from the dropdown list, it should be selected in the editor. This is the way Windows combos work. ###@###.### 2001-07-17 ======================================================================
2001-07-17

SUGGESTED FIX Name: pzR10082 Date: 07/17/2001 This fix is for part 2: in an editable combo, when an item is choosen from the dropdown list, it should be selected in the editor. *** /tmp/geta29904 Mon Jul 16 19:39:46 2001 --- WindowsComboBoxUI.java Mon Jul 16 19:35:24 2001 *************** *** 56,61 **** --- 56,73 ---- return new WindowsComboPopup( comboBox ); } + /** + * Creates the default editor that will be used in editable combo boxes. + * A default editor will be used only if an editor has not been + * explicitly set with <code>setEditor</code>. + * + * @return a <code>ComboBoxEditor</code> used for the combo box + * @see javax.swing.JComboBox#setEditor + */ + protected ComboBoxEditor createEditor() { + return new WindowsComboBoxEditor(); + } + /** * Subclassed to add Windows specific Key Bindings. * This class is now obsolete and doesn't do anything. *************** *** 104,108 **** --- 116,132 ---- } } } + } + + /** + * Subclassed to highlight selected item in an editable combo box. + */ + public static class WindowsComboBoxEditor + extends BasicComboBoxEditor.UIResource { + + public void setItem(Object item) { + super.setItem(item); + selectAll(); + } } } ###@###.### 2001-07-17 ======================================================================
2001-07-17