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

Hovering Metal HTML Tooltips in different windows cause IllegalArgExc on Linux

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b12
    • CPU:
      x86_64
    • OS:
      linux_redhat_6.0

      Description

      ADDITIONAL SYSTEM INFORMATION :
      Linux 3.10.0-1127.19.1.el7.x86_64 #1 SMP Tue Aug 25 17:23:54 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
      openjdk version "11.0.8" 2020-07-14 LTS
      OpenJDK Runtime Environment 18.9 (build 11.0.8+10-LTS)
      OpenJDK 64-Bit Server VM 18.9 (build 11.0.8+10-LTS, mixed mode, sharing)




      A DESCRIPTION OF THE PROBLEM :
      If an application has components with tooltips that contain HTML content, and also a dialog with components with tooltips that contain HTML content, quickly moving the mouse from one such component in the main window to another such component in the dialog window can eventually trigger the exception documented below.

      When debugging, I could see that in my case, the JToolTip's width, height, and all insets were 1 at the time of the exception, which caused a width of -1 and a height of -1 to be provided to BasicHTML.getHTMLBaseline .

      I ran the demo program also on a Windows PC with openjdk-15.0.1-x64, and did not manage to reproduce the exception there.

      Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Width and height must be >= 0
      at java.desktop/javax.swing.plaf.basic.BasicHTML.getHTMLBaseline(BasicHTML.java:91)
      at java.desktop/javax.swing.plaf.metal.MetalToolTipUI.paint(MetalToolTipUI.java:126)
      at java.desktop/javax.swing.plaf.ComponentUI.update(ComponentUI.java:161)
      at java.desktop/javax.swing.JComponent.paintComponent(JComponent.java:797)
      at java.desktop/javax.swing.JComponent.paint(JComponent.java:1074)
      at java.desktop/javax.swing.JComponent.paintChildren(JComponent.java:907)
      at java.desktop/javax.swing.JComponent.paint(JComponent.java:1083)
      at java.desktop/javax.swing.JComponent.paintChildren(JComponent.java:907)
      at java.desktop/javax.swing.JComponent.paint(JComponent.java:1083)
      at java.desktop/javax.swing.JLayeredPane.paint(JLayeredPane.java:590)
      at java.desktop/javax.swing.JComponent.paintChildren(JComponent.java:907)
      at java.desktop/javax.swing.JComponent.paintToOffscreen(JComponent.java:5262)
      at java.desktop/javax.swing.RepaintManager$PaintManager.paintDoubleBufferedImpl(RepaintManager.java:1643)
      at java.desktop/javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1618)
      at java.desktop/javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1556)
      at java.desktop/javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:262)
      at java.desktop/javax.swing.RepaintManager.paint(RepaintManager.java:1323)
      at java.desktop/javax.swing.JComponent.paint(JComponent.java:1060)
      at java.desktop/java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:39)
      at java.desktop/sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:78)
      at java.desktop/sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:115)
      at java.desktop/java.awt.Container.paint(Container.java:2002)
      at java.desktop/java.awt.Window.paint(Window.java:3940)
      at java.desktop/javax.swing.RepaintManager$4.run(RepaintManager.java:876)
      at java.desktop/javax.swing.RepaintManager$4.run(RepaintManager.java:848)
      at java.base/java.security.AccessController.doPrivileged(Native Method)
      at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
      at java.desktop/javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:848)
      at java.desktop/javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:823)
      at java.desktop/javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:772)
      at java.desktop/javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1890)
      at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
      at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770)
      at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
      at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
      at java.base/java.security.AccessController.doPrivileged(Native Method)
      at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
      at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:740)
      at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
      at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
      at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
      at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
      at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
      at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Start the demo program, or
      Create an application with
      1. a main window with a label that has a tooltip with HTML content
      2. a dialog window with a label that has a tooltip with HTML content

      Hover over one of the labels to see the tooltip. Quickly, wiggle the mouse to move the mouse between the two labels.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The tooltips should show, no exceptions should be thrown.
      ACTUAL -
      After switching between the labels with the tooltips multiple times, receive exception
      Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Width and height must be >= 0 .

      ---------- BEGIN SOURCE ----------
      package anne.bugs;

      import java.awt.Color;

      import javax.swing.JDialog;
      import javax.swing.JFrame;
      import javax.swing.JLabel;
      import javax.swing.SwingUtilities;
      import javax.swing.WindowConstants;

      public class TooltipBugDemo {

          public static void main(String[] args) {
              SwingUtilities.invokeLater(() -> {
                  final JFrame frame = new JFrame("Swing Tooltip Bug Demo");
                  frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
                  frame.setSize(250, 250);

                  frame.add(createLabel("main content, hover me", Color.CYAN, "main tooltip"));
                  frame.setVisible(true);

                  final JDialog dialog = new JDialog(frame, "Dialog Window", false);
                  dialog.setContentPane(createLabel("dialog content, hover me", Color.YELLOW, "dialog tooltip"));
                  dialog.pack();
                  dialog.setVisible(true);
              });
          }

          private static JLabel createLabel(final String labelText, final Color bgColor, final String tooltipContent) {
              final JLabel label = new JLabel(labelText);
              label.setOpaque(true);
              label.setBackground(bgColor);
              label.setToolTipText(createTooltipText(tooltipContent));
              return label;
          }

          private static String createTooltipText(String text) {
              return "<html><h1>" + text + "</h1></html>";
          }

      }
      ---------- END SOURCE ----------

      FREQUENCY : often


        Attachments

          Issue Links

            Activity

              People

              Assignee:
              azvegint Alexander Zvegintsev
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: