JDK-8224576 : Swing: GIF images in HTML tooltips are not rendered
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 8u202,11.0.2,12.0.1
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_7
  • CPU: x86_64
  • Submitted: 2019-05-17
  • Updated: 2019-12-17
  • Resolved: 2019-12-17
Related Reports
Duplicate :  
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
Windows 7, 64 Bit, AdoptJDK12.0.1+12 64 Bit

A DESCRIPTION OF THE PROBLEM :
GIF images in HTML tooltips are not rendered under circumstances when referenced from resource.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Add a tooltip text with html tooltip containing an image ("<img src=..." from resource or http) to a Swing control (e.g. JButton).
Hovering over the button reveals tooltip with or without image under certain (unknown) circumstances.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The tooltips should show the images from the URL and the resource URL.
But it does not.
ACTUAL -
Only some images in the tooltip are rendered.
Tooltips do not render correct size.

---------- BEGIN SOURCE ----------
package components;

import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;

public class TestImageToolTip {

    public static void main(String[] args) {
        JDialog dlg = new JDialog();
        final JPanel p = new JPanel();
        p.setLayout(new GridLayout(3, 1));
        dlg.add(p);

        final JButton labelVersion = new JButton(String.format("Java Version: %s - %s",
                System.getProperty("java.vendor"), System.getProperty("java.version")));
        p.add(labelVersion);
        final JButton labelQuilt = new JButton("quilt tooltip here");
        p.add(labelQuilt);
        labelQuilt.setToolTipText(String.format("<html>%s<br>http: <img src=\"%s\"/><br>resource: <img src=\"%s\"/></html>",
                "Quilt",
                "https://upload.wikimedia.org/wikipedia/commons/b/bb/Quilt_design_as_46x46_uncompressed_GIF.gif",
                TestImageToolTip.class.getResource("/Quilt_design_as_46x46_uncompressed_GIF.gif")));
        final JButton label5Cell = new JButton("5-cell-tooltip here");
        p.add(label5Cell);
        label5Cell.setToolTipText(String.format("<html>%s: http: <img src=\"%s\"/> resource: <img src=\"%s\"/></html>",
                "5-cell",
                "https://upload.wikimedia.org/wikipedia/commons/thumb/d/d8/5-cell.gif/28px-5-cell.gif",
                TestImageToolTip.class.getResource("/28px-5-cell.gif")));
        dlg.getContentPane().add(p);
        dlg.pack();
        dlg.setModal(true);
        dlg.setVisible(true);
        dlg.dispose();
    }
}

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

FREQUENCY : always



Comments
This is likely a duplicate of JDK-8218674 which has fix for JDK 13. Writing back to submitter to confirm status with JDK 13.
22-05-2019

GIF images in HTML tooltips usng "<img src=..."> from resource or http fails to render. Reported with JDK 12.0.1, could confirm the issue. This does not reproduce with JDK 13 though. Result: ====== 8u201: OK 8u202: Fail 8u212: Fail 8u221: Fail 9: OK 11.0.1: OK 11.0.2: Fail 12.0.1: Fail 13 ea b20: OK This is a regression in JDK 8u202. To verify, run the attached test case with respective JDK version.
22-05-2019