JDK-8213535 : Windows HiDPI html lightweight tooltips are truncated
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 10,11,12,13,14,15
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_10
  • CPU: x86_64
  • Submitted: 2018-10-30
  • Updated: 2020-11-26
  • Resolved: 2020-06-25
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 11 JDK 13 JDK 16
11.0.10-oracleFixed 13.0.6Fixed 16 b05Fixed
Related Reports
Duplicate :  
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
Windows 10 with HiDPI display with everything scaled at 200%

A DESCRIPTION OF THE PROBLEM :
HTML tooltips aren't big enough to contain their contents on Windows HiDPI displays, so the final word on a line wraps to the next line. If it is a multi-line tooltip, then the final line is missing entirely.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached program. Mouse over the button and wait for the tooltip to appear

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The tooltip says "Some tooltip text"
ACTUAL -
The tooltip says "Some tooltip"

---------- BEGIN SOURCE ----------
package com.company;

import javax.swing.*;
import java.awt.*;

public class TruncatedTooltip {

    public static void main(String[] args) {
        // Demonstrate that the tooltip contents are truncated when the tooltip is lightweight (entirely within the window bounds) on Windows HiDPI displays
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            JButton button = new JButton("toggle height");
            button.setToolTipText("<html>Some tooltip text<html>");
            JFrame frame = new JFrame();
            frame.getContentPane().setLayout(new FlowLayout());
            frame.getContentPane().add(button);
            frame.setSize(400,200);
            frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
            frame.setVisible(true);
            button.addActionListener(e -> frame.setSize(300,frame.getHeight()<200?200:40));
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Click the button which decreases the size of the window enough such that the tooltip needs to extend outside of the window bounds. It displays correctly as a heavy weight tooltip. 

This bug does not happen under Java 9.

This bug does not happen if the Windows look and feel is not set.

FREQUENCY : always



Comments
Fix Request (13u) Requesting backport to 13u for parity with 11u. The original patch applies cleanly and fixes the problem. Tested with jdk/javax/swing, no regressions.
10-11-2020

Fix Request (11u) I would like to backport this patch to 11u for parity with 11.0.10-oracle. The original patch does not apply cleanly, 11u fix has been reviewed.
03-09-2020

11u code review: https://mail.openjdk.java.net/pipermail/jdk-updates-dev/2020-August/003657.html
26-08-2020

URL: https://hg.openjdk.java.net/jdk/jdk/rev/71df50d2926b User: psadhukhan Date: 2020-07-03 13:30:55 +0000
03-07-2020

URL: https://hg.openjdk.java.net/jdk/client/rev/71df50d2926b User: serb Date: 2020-06-25 01:38:06 +0000
25-06-2020

http://mail.openjdk.java.net/pipermail/swing-dev/2020-June/010476.html
22-06-2020

http://mail.openjdk.java.net/pipermail/swing-dev/2020-March/010274.html
02-04-2020

Issue is being worked on for proper fix. Meanwhile, as a workaround the application can use this line UIManager.put("ToolTip.font", new FontUIResource("SansSerif", Font.PLAIN, 12)); before button.setToolTipText("<html>Some tooltip text<html>");
27-03-2020

[~psadhukhan] any progress after https://mail.openjdk.java.net/pipermail/swing-dev/2019-December/009992.html ?
26-01-2020

https://mail.openjdk.java.net/pipermail/swing-dev/2019-December/009992.html
17-12-2019

http://mail.openjdk.java.net/pipermail/swing-dev/2019-April/009579.html
21-05-2019

JDK-8178025 updates GlyphPainter1#FontMetrics in sync() method if current metrics is different from Container's fontmetrics. Even if the affinetransform is modified, metrics is updated as FontMetrics would have changed because of the transform. If we comment this line "|| (! metrics.equals(fm)))" from the fix, this issue works. This is causing problem in tooltip html text rendering as tooltip text is using affinetransform of 1 [found out by calling tip.getFont().getTransform()] whereas it should be using 1.25 (default) in windows10 in hidpi mode. Tried using tip.setFont(tip.getFont().deriveFont(tx)); where tx is 1.25 in TooltipManager#showTipWindow() before we do tip.setTipText(toolTipText); but still it does not help. Maybe Phil can help as it has something to do with font and fontmetrics.
27-11-2018

Looks like regression of JDK-8178025
22-11-2018

Failing from jdk10b34 build. https://bugs.openjdk.java.net/browse/JDK-8191616?filter=34966&jql=project%20%3D%20JDK%20AND%20issuetype%20in%20(Bug%2C%20Enhancement)%20AND%20resolution%20%3D%20Fixed%20AND%20fixVersion%20%3D%20%2210%22%20AND%20component%20%3D%20client-libs%20AND%20%22Resolved%20In%20Build%22%20%3D%20b34%20ORDER%20BY%20assignee%20ASC%2C%20priority%20DESC%2C%20key%20DESC
09-11-2018

Windows 10 with HiDPI display and when scaled at 175% or more displays html lightweight tool tips as truncated from JDK aa and onward. Checked this with reported version and could confirm the issue. Result: ======== 8u191: OK 10.0.2: OK 11: Fail 11.0.1: Fail 12 ea b18: Fail This is a regression in JDK 11. To verify, run the attached test case with respective JDK versions.
08-11-2018