Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6337516

NullPointerException in ToolTipManager on mouseExit

XMLWordPrintable

    • b15
    • generic, x86
    • linux, windows, windows_2000
    • Verified

        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

              alexp Alexander Potochkin (Inactive)
              jssunw Jitender S (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: