United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 2149906 NullPointerException in ToolTipManager on mouseExit
2149906 : NullPointerException in ToolTipManager on mouseExit

Details
Type:
Backport
Submit Date:
2007-06-05
Status:
Resolved
Updated Date:
2011-01-19
Project Name:
JDK
Resolved Date:
2007-06-30
Component:
client-libs
OS:
Sub-Component:
javax.swing
CPU:
Priority:
P3
Resolution:
Fixed
Affected Versions:
Fixed Versions:
6u4

Related Reports
Backport:

Sub Tasks

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
*** (#1 of 1): 2005-10-17 12:31:59 MSD ###@###.###

                                    

Comments
EVALUATION

see evaluation from the main CR
                                     
2007-06-18



Hardware and Software, Engineered to Work Together