This fixes one weird NPE (see associated bug report) and I also cleaned
up some inconsistencies that I came over and some warnings that Eclipse
came over :-)
2007-01-06 Roman Kennke [EMAIL PROTECTED]
PR 30337
* javax/swing/plaf/basic/BasicComboBoxUI.java
(installUI): Install popup and list here.
Don't configure the arrow button and editor here.
(installComponents): Don't install popup and list here. (Moved
to installUI). Configure arrow button here and check for null.
(addEditor): Configure editor here.
(configureArrowButton): Directly fetch listeners from popup.
(paintCurrentValue): Removed unused local variables.
(layoutContainer): Removed unused local variables.
(PropertyChangeHandler.propertyChange): Don't invalidate minimumSize
on each property change. Avoid calling getPropertyName() repeatedly.
Clean up. Call addEditor() when editor changes. Configure and
unconfigure editor when editable changes. Use 'model' instead
of non-existing 'dataModel' property.
* javax/swing/plaf/basic/BasicComboPopup.java
(uninstallingUI): Remove property change listener and item listener
here. Uninstall list listeners. Set model to null to prevent leakage.
(configureList): Don't sync list selection there.
(uninstallComboBoxListeners): Moved to uninstallingUI.
(uninstallListeners): Moved to uninstallingUI.
* javax/swing/plaf/metal/MetalComboBoxUI.java
(createPopup): Call super.
(getMinimumSize): Removed unused statement.
/Roman
Index: javax/swing/plaf/basic/BasicComboBoxUI.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicComboBoxUI.java,v
retrieving revision 1.40
diff -u -1 -5 -r1.40 BasicComboBoxUI.java
--- javax/swing/plaf/basic/BasicComboBoxUI.java 24 Jul 2006 15:04:05 - 1.40
+++ javax/swing/plaf/basic/BasicComboBoxUI.java 6 Jan 2007 15:38:45 -
@@ -203,52 +203,49 @@
* Installs the UI for the given [EMAIL PROTECTED] JComponent}.
*
* @param c the JComponent to install a UI for.
*
* @see #uninstallUI(JComponent)
*/
public void installUI(JComponent c)
{
super.installUI(c);
if (c instanceof JComboBox)
{
isMinimumSizeDirty = true;
comboBox = (JComboBox) c;
installDefaults();
+popup = createPopup();
+listBox = popup.getList();
// Set editor and renderer for the combo box. Editor is used
// only if combo box becomes editable, otherwise renderer is used
// to paint the selected item; combobox is not editable by default.
ListCellRenderer renderer = comboBox.getRenderer();
if (renderer == null || renderer instanceof UIResource)
comboBox.setRenderer(createRenderer());
ComboBoxEditor currentEditor = comboBox.getEditor();
if (currentEditor == null || currentEditor instanceof UIResource)
{
currentEditor = createEditor();
comboBox.setEditor(currentEditor);
}
-editor = currentEditor.getEditorComponent();
installComponents();
installListeners();
-if (arrowButton != null)
- configureArrowButton();
-if (editor != null)
- configureEditor();
comboBox.setLayout(createLayoutManager());
comboBox.setFocusable(true);
installKeyboardActions();
comboBox.putClientProperty(BasicLookAndFeel.DONT_CANCEL_POPUP,
Boolean.TRUE);
}
}
/**
* Uninstalls the UI for the given [EMAIL PROTECTED] JComponent}.
*
* @param c The JComponent that is having this UI removed.
*
* @see #installUI(JComponent)
*/
@@ -461,37 +458,35 @@
* @return A new component that will be responsible for displaying/editing
* the selected item in the combo box.
*/
protected ComboBoxEditor createEditor()
{
return new BasicComboBoxEditor.UIResource();
}
/**
* Installs the components for this JComboBox. ArrowButton, main
* part of combo box (upper part) and popup list of items are created and
* configured here.
*/
protected void installComponents()
{
-// create drop down list of items
-popup = createPopup();
-listBox = popup.getList();
-
// create and install arrow button
arrowButton = createArrowButton();
comboBox.add(arrowButton);
+if (arrowButton != null)
+ configureArrowButton();
if (comboBox.isEditable())
addEditor();
comboBox.add(currentValuePane);
}
/**
* Uninstalls components from this [EMAIL PROTECTED] JComboBox}.
*
* @see #installComponents()
*/
protected void uninstallComponents()
{
// uninstall arrow button
@@ -509,31 +504,35 @@
ComboBoxEditor