JDK-4842445 : ClassCastException in BasicComboboxUI using Multi-UI
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2003-04-03
  • Updated: 2003-08-12
  • Resolved: 2003-08-12
Related Reports
Duplicate :  
Description

Name: jk109818			Date: 04/03/2003


FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

FULL OPERATING SYSTEM VERSION :
Microsoft Windows 2000 [Version 5.00.2195]

ADDITIONAL OPERATING SYSTEMS :
not tested


A DESCRIPTION OF THE PROBLEM :
When using an auxiliary Look and Feel, java uses
automatically the Multi LAF as UI delegate. However the
BasicComboBoxUI expects to have a BasicComboboxUI installed
on a JCombobox when performing the UpAction.
The following code snippet comes from BasicComboBoxUI.java in
the src.zip from the SDK:

static class UpAction extends AbstractAction {
	public void actionPerformed(ActionEvent e) {
	    JComboBox comboBox = (JComboBox)e.getSource();
	    if ( comboBox.isEnabled() ) {
		BasicComboBoxUI ui = (BasicComboBoxUI)comboBox.getUI();
		if (ui.isPopupVisible(comboBox)) {
                    ui.selectPreviousPossibleValue();
                }
            }
        }
    }

When using a Multi-LAF the cast to a BasicComboBoxUI is not
legal an causes an exception:

java.lang.ClassCastException:
javax.swing.plaf.multi.MultiComboBoxUI
	at
javax.swing.plaf.basic.BasicComboBoxUI$UpAction.actionPerfor
med(BasicComboBoxUI.java:1530)
	at javax.swing.SwingUtilities.notifyAction
(SwingUtilities.java:1502)
	at javax.swing.JComponent.processKeyBinding
(JComponent.java:2422)
	at javax.swing.JComponent.processKeyBindings
(JComponent.java:2468)
	at javax.swing.JComponent.processKeyEvent
(JComponent.java:2385)
	at java.awt.Component.processEvent
(Component.java:4830)
	at java.awt.Container.processEvent
(Container.java:1380)

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. install an auxiliary Look and Feel (either by setting
the property or by doing it by run time)
2. use a combobox
3. pop it up and press the UP-Key

EXPECTED VERSUS ACTUAL BEHAVIOR :
normally the selected entry in the popup window of the
combobox moves up one entry.

When using a Multi-LAF an exception occurs

ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.ClassCastException: javax.swing.plaf.multi.MultiComboBoxUI
	at javax.swing.plaf.basic.BasicComboBoxUI$UpAction.actionPerformed
(BasicComboBoxUI.java:1530)
	at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1502)
	at javax.swing.JComponent.processKeyBinding(JComponent.java:2422)
	at javax.swing.JComponent.processKeyBindings(JComponent.java:2468)
	at javax.swing.JComponent.processKeyEvent(JComponent.java:2385)
	at java.awt.Component.processEvent(Component.java:4830)
	at java.awt.Container.processEvent(Container.java:1380)

REPRODUCIBILITY :
This bug can be reproduced always.
(Review ID: 179623) 
======================================================================

Comments
EVALUATION This was fixed as part of the actions reworking that was done for synth: 4632193. ###@###.### 2003-08-12
12-08-2003