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