-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.3.0
-
generic
-
generic
Name: skT45625 Date: 05/15/2000
java version "1.2.2"
Classic VM (build JDK-1.2.2-001, native threads, symcjit)
BasicComboBoxUI does not completely uninstall itself on
UIManager.setLookAndFeel. Specifically, it leaves a FocusListener attached to
the combobox editor. The file version I have is "BasicComboBoxUI.java 1.100
99/04/22". The FocusListener is added on line 585 of BasicComboBoxUI.java. This
listener should be removed from the editor in unconfigureEditor (which will
handle UI changes and editor changes). The fix should be trivial (if it isn't
already fixed in a more recent version).
<P>
Source code that exercises this bug follows:
<PRE>
import javax.swing.*;
import java.beans.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.plaf.basic.*;
public class ComboBugApp extends javax.swing.JFrame
implements ActionListener
{
JComboBox m_comboBox = new JComboBox();
public ComboBugApp()
{
// set up a menu to change the look and feel
JMenuBar menubar = new JMenuBar();
setJMenuBar(menubar);
JMenu lafmenu = new JMenu("Look and Feel");
menubar.add(lafmenu);
UIManager.LookAndFeelInfo[] lafInfo =
UIManager.getInstalledLookAndFeels();
for( int i = 0; i < lafInfo.length; i++ )
{
JMenuItem item = new JMenuItem(lafInfo[i].getName());
item.setActionCommand(lafInfo[i].getClassName());
item.addActionListener(this);
lafmenu.add(item);
}
getContentPane().setLayout(new FlowLayout());
String[] aData = {"This", "is", "a", "test"};
m_comboBox = new JComboBox( aData );
m_comboBox.setEditable(true);
getContentPane().add( m_comboBox );
// Make sure the window closes - Is there a better way to do this?
this.addWindowListener(
new WindowAdapter()
{
public void windowClosing(java.awt.event.WindowEvent event)
{
Object object = event.getSource();
if (object == ComboBugApp.this)
{
dispose();
System.exit(0);
}
}
}
);
pack();
}
public void actionPerformed(ActionEvent e)
{
if( e.getSource() instanceof JMenuItem )
{
// Change the look and feel
try
{
UIManager.setLookAndFeel(e.getActionCommand());
SwingUtilities.updateComponentTreeUI(this);
pack();
}
catch( Exception ex )
{
System.out.println(ex);
}
}
}
public static void main(String[] args)
{
new ComboBugApp().setVisible(true);
}
}
</PRE>
<P>
To reproduce: Run the program. Change the look and feel. Click on the combobox.
<P>
The bug generates the following call stack:
<PRE>
Exception occurred during event dispatching:
java.lang.NullPointerException
at
javax.swing.plaf.basic.BasicComboBoxUI$2.focusLost(BasicComboBoxUI.java:587)
at java.awt.AWTEventMulticaster.focusLost(AWTEventMulticaster.java:171)
at java.awt.Component.processFocusEvent(Component.java:3087)
at javax.swing.JComponent.processFocusEvent(JComponent.java:1500)
at java.awt.Component.processEvent(Component.java:2990)
at java.awt.Container.processEvent(Container.java:990)
at java.awt.Component.dispatchEventImpl(Component.java:2394)
at java.awt.Container.dispatchEventImpl(Container.java:1035)
at java.awt.Component.dispatchEvent(Component.java:2307)
at java.awt.LightweightDispatcher.processFocusEvent(Container.java:1778)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:1735)
at java.awt.Container.dispatchEventImpl(Container.java:1022)
at java.awt.Window.dispatchEventImpl(Window.java:749)
at java.awt.Component.dispatchEvent(Component.java:2307)
at java.awt.LightweightDispatcher.setFocusRequest(Container.java:1685)
at java.awt.Container.proxyRequestFocus(Container.java:1215)
at java.awt.Container.proxyRequestFocus(Container.java:1210)
at java.awt.Container.proxyRequestFocus(Container.java:1210)
at java.awt.Container.proxyRequestFocus(Container.java:1210)
at java.awt.Container.proxyRequestFocus(Container.java:1210)
at java.awt.Component.requestFocus(Component.java:3545)
at javax.swing.JComponent.requestFocus(JComponent.java:754)
at
javax.swing.plaf.basic.BasicComboPopup.delegateFocus(BasicComboPopup.java:753)
at
javax.swing.plaf.basic.BasicComboPopup$InvocationMouseHandler.mousePressed(Basic
ComboPopup.java:424)
at java.awt.Component.processMouseEvent(Component.java:3157)
at java.awt.Component.processEvent(Component.java:2999)
at java.awt.Container.processEvent(Container.java:990)
at java.awt.Component.dispatchEventImpl(Component.java:2394)
at java.awt.Container.dispatchEventImpl(Container.java:1035)
at java.awt.Component.dispatchEvent(Component.java:2307)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:2043)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:1821)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:1730)
at java.awt.Container.dispatchEventImpl(Container.java:1022)
at java.awt.Window.dispatchEventImpl(Window.java:749)
at java.awt.Component.dispatchEvent(Component.java:2307)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:287)
at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:103)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:92)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:83)
</PRE>
This doesn't seem to be anywhere else in the bug database. I hope this is enough
information. I will not be resubmitting it if this report is rejected again.
(Review ID: 104826)
======================================================================
- duplicates
-
JDK-4256304 NullPointerException in JComboBox during change of look&Feel
-
- Resolved
-