JDK-5050506 : NullPointerException from ToolTipManager
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.2
  • Priority: P4
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2004-05-20
  • Updated: 2004-05-28
  • Resolved: 2004-05-28
Related Reports
Relates :  
Description

Name: rmT116609			Date: 05/20/2004


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

java version "1.5.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32c)
Java HotSpot(TM) Client VM (build 1.5.0-beta-b32c, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
When a component is removed while its tooltip is displayed, the tooltip remains visible for some time. Under circumstances this tooltip functions like a landmine - move the mouse cursor over it and you get a NPE.

This could possibly be a duplicate of Bug 5041071, but I'm not sure since there is not much description.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run my test application. There is a frame that contains two JLabels, both with a ToolTipText. Important is Label 2. Move the mouse cursor over Label 2 so that the tooltip is displayed. Then press the 'Del' button on the keyboard which causes this Label 2 to be removed. Now move the mouse cursor over the tooltip that will remain visible for a few seconds, and at mouseExit() occasionally a NPE occurs. It occurs always when the (very long) tooltip of Label 1 has been displayed before.


ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.NullPointerException
	at javax.swing.ToolTipManager.mouseExited(ToolTipManager.java:532)
	at java.awt.Component.processMouseEvent(Component.java:5106)
	at java.awt.Component.processEvent(Component.java:4897)
	at java.awt.Container.processEvent(Container.java:1569)
	at java.awt.Window.processEvent(Window.java:1092)
	at java.awt.Component.dispatchEventImpl(Component.java:3615)
	at java.awt.Container.dispatchEventImpl(Container.java:1627)
	at java.awt.Window.dispatchEventImpl(Window.java:1606)
	at java.awt.Component.dispatchEvent(Component.java:3477)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
	at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;

public class ToolTipBug
{
    public static void main(String[] P_args)
    {
        final JFrame frame = new JFrame();
        frame.addWindowListener (new WindowAdapter()
        {
            public void windowClosing(WindowEvent e) { System.exit(0); }
        });

        frame.getContentPane().setLayout(new FlowLayout(FlowLayout.LEFT, 40, 40));

        final JLabel la1 = new JLabel("Label 1");
        la1.setBorder(new LineBorder(Color.black, 1));
        la1.setToolTipText("ToolTipText too long for Window -- ToolTipText too long for Window");
        frame.getContentPane().add(la1);

        final JLabel la = new JLabel("Label 2");
        la.setBorder(new LineBorder(Color.black, 1));
        la.setToolTipText("ToolTipText");
        frame.getContentPane().add(la);

        frame.addKeyListener(new KeyListener()
        {
            public void keyPressed(KeyEvent e)
            {
                frame.getContentPane().remove(la);
                frame.repaint();
            }
            public void keyReleased(KeyEvent e) {}
            public void keyTyped(KeyEvent e) {}
        });

        frame.pack();
        frame.setVisible(true);
    }
}

---------- END SOURCE ----------
(Incident Review ID: 270011) 
======================================================================

Comments
EVALUATION Name: apR10262 Date: 05/28/2004 Bug is easily reproducible on JDK 1.4.2 but is not reproducible on JDK 1.5 build 1.5.0-beta2-b48 ======================================================================
24-08-2004