JDK-6337516 : NullPointerException in ToolTipManager on mouseExit
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 5.0,6
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: linux,windows,windows_2000
  • CPU: generic,x86
  • Submitted: 2005-10-17
  • Updated: 2011-03-08
  • Resolved: 2011-03-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7
6u4Fixed 7 b15Fixed
Related Reports
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
Linux pav.pavhome.lan 2.6.13.1 #1 SMP Thu Sep 15 09:45:56 CEST 2005 i686 Intel(R) Pentium(R) 4 CPU 2.80GHz GenuineIntel GNU/Linux


A DESCRIPTION OF THE PROBLEM :
It is possible to receive a NullPointerException from ToolTipManager when the mouse exits a tooltip belonging to a component that has been removed from its container since the tooltip was displayed. This appears to be the same bug as 5050506, marked non reproducable. This only appears to happen if the tooltip is heavyweight, i.e. if it extends out of the frame/dialog

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) trigger a tooltip that extends out of the frame
2) move mouse onto tooltip
3) remove component from frame before tooltip vanishes
4) move mouse out of tooltip

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No NPE

ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
        at javax.swing.ToolTipManager.mouseExited(ToolTipManager.java:498)
        at java.awt.Component.processMouseEvent(Component.java:5494)
        at java.awt.Component.processEvent(Component.java:5253)
        at java.awt.Container.processEvent(Container.java:1966)
        at java.awt.Window.processEvent(Window.java:1153)
        at java.awt.Component.dispatchEventImpl(Component.java:3955)
        at java.awt.Container.dispatchEventImpl(Container.java:2024)
        at java.awt.Window.dispatchEventImpl(Window.java:1766)
        at java.awt.Component.dispatchEvent(Component.java:3803)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

REPRODUCIBILITY :
This bug can be reproduced always.

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


/*
 * Attempts to trigger ToolTipManager bug.
 * 1) Compile and run.
 * 2) Wait till 'trigger tooltip' message displayed, them move mouse over component to trigger tooltip,
 * followed by immediately moving mouse onto tooltip. Tooltip location varies slightly and if there is a gap
 * this step can be difficult.
 * 3) wait for 'please remove' message and move mouse out of tooltip.
 * 4) NPE
 */
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;

/*
 *  Attempts to trigger ToolTipManager bug.
 *  compile, run and wait. Do not touch the mouse.
 */
public class TestTooltip {
  private static final int XOFFSET=30;
  private static final int YOFFSET=30;
  public static void main(String[] args) throws Exception{
    final JFrame window = new JFrame();
    final JComponent comp = new JButton("A component");

    window.getContentPane().add(comp);
    comp.setToolTipText("this is a reasonably long tool tip");
    window.pack();
    window.setLocationRelativeTo(null);
    window.setVisible(true);
    Robot robot = new Robot();
    waitabit(1000);
    Point p = comp.getLocationOnScreen();
    robot.mouseMove(p.x-5, p.y-5);
    robot.mouseMove(p.x, p.y);
    robot.mouseMove(p.x+5, p.y+5);
    waitabit(2000); //trigger tooltip
    robot.mouseMove(p.x+XOFFSET, p.y+YOFFSET); //move the mouse onto the 
tooltip - you may need to adjust these numbers.
    waitabit(500);
    
    window.getContentPane().removeAll();
    window.repaint();
    robot.mouseMove(0,0);
  }

  public static void waitabit(long pauseLength) {
    Object lock = new Object();

    synchronized (lock) {
      try {
        lock.wait(pauseLength);
      } catch (InterruptedException e) {
      }
    }
  }
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
not available

Comments
EVALUATION in ToolTipManager line #478 we check if topLevel is null we need to do the same check for the first if()
06-06-2007

EVALUATION Contribution forum : https://jdk-collaboration.dev.java.net/servlets/ProjectForumMessageView?forumID=1463&messageID=13408
08-06-2006

EVALUATION ToolTipManager supposes that on tooltip mouseExited event component is visible. Need to check it
27-10-2005