JDK-8259913 : AWT menu items are not scaled correctly on Windows HiDPI displays
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 11,15,20,21
  • Priority: P4
  • Status: In Progress
  • Resolution: Unresolved
  • OS: windows_10
  • CPU: x86_64
  • Submitted: 2021-01-13
  • Updated: 2024-06-24
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.
Other
tbdUnresolved
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
Windows 10 with HiDPI display scaled at 300% or larger.


Tested this with Java "11.0.9.1", "15.0.1".

- Oracle JDK

java version "11.0.9" 2020-10-20 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.9+7-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.9+7-LTS, mixed mode)

- Oracle OpenJDK

openjdk version "15.0.1" 2020-10-20
OpenJDK Runtime Environment (build 15.0.1+9-18)
OpenJDK 64-Bit Server VM (build 15.0.1+9-18, mixed mode, sharing)

- Adopt OpenJDK

openjdk version "11.0.9.1" 2020-11-04
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.9.1+1)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.9.1+1, mixed mode)

openjdk version "15.0.1" 2020-10-20
OpenJDK Runtime Environment (build 15.0.1+9-18)
OpenJDK 64-Bit Server VM (build 15.0.1+9-18, mixed mode, sharing)

- Azul Zulu

openjdk version "11.0.9.1" 2020-11-04 LTS
OpenJDK Runtime Environment Zulu11.43+55-CA (build 11.0.9.1+1-LTS)
OpenJDK 64-Bit Server VM Zulu11.43+55-CA (build 11.0.9.1+1-LTS, mixed mode)

openjdk version "15.0.1" 2020-10-20
OpenJDK Runtime Environment Zulu15.28+51-CA (build 15.0.1+9)
OpenJDK 64-Bit Server VM Zulu15.28+51-CA (build 15.0.1+9, mixed mode, sharing)

A DESCRIPTION OF THE PROBLEM :
On Windows 10 with a HiDPI display that has a large scaling factor (for instance 300%), the menu items from the tray icon menu overlap and are hard to read. Also, the small arrow icon used for submenus is not visible.

The font for the menu items seem to be scaled correctly but not their height.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
This problem can be reproduced with the TrayIconDemo.java [1] class available from the "How to Use the System Tray" tutorial [2].

1. TrayIconDemo.java
https://docs.oracle.com/javase/tutorial/uiswing/examples/misc/TrayIconDemoProject/src/misc/TrayIconDemo.java
https://docs.oracle.com/javase/tutorial/uiswing/examples/misc/TrayIconDemoProject/src/misc/images/bulb.gif

2. How to Use the System Tray
https://docs.oracle.com/javase/tutorial/uiswing/misc/systemtray.html


Run TrayIconDemo.java on a Windows system with a HiDPI display that uses a scaling factor of 300% or larger. Alternatively, this problem can be reproduced on non-HiDPI displays if TrayIconDemo.java is ran with -Dsun.java2d.uiScale=3.

Click the tray icon to see the tray icon menu.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
- There's enough space between menu items that they don't overlap
- The blue rectangle for the selected menu item is larger than the text
- The arrow icon for the "Display" menu item is visible
ACTUAL -
- Menu items overlap and are hard to read
- The arrow icon for the "Display" menu item is not visible

---------- BEGIN SOURCE ----------
https://docs.oracle.com/javase/tutorial/uiswing/examples/misc/TrayIconDemoProject/src/misc/TrayIconDemo.java
https://docs.oracle.com/javase/tutorial/uiswing/examples/misc/TrayIconDemoProject/src/misc/images/bulb.gif
---------- END SOURCE ----------

FREQUENCY : always



Comments
Perhaps, we should enable adding JPopupMenu to a tray icon. There are several requests for this functionality: JDK-6575405, JDK-6471755, JDK-6287100. JPopupMenu supports High DPI scaling.
25-03-2024

Updated the summary, we know that not only tray menu is affected, all menu items are affected. Now the subject is closer to that of JDK-8310641.
18-10-2023

measureInfo.itemHeight += measureInfo.itemHeight/3 This line seems to have an effect on the overlapping menu items. It says 3 is a heuristic number, I think the added height should be a function of scale so that the value changes according to the current scale. Looking into it further. https://github.com/openjdk/jdk/blob/8e4cda063c96f285d4659dbf5bc8bd064393ee93/src/java.desktop/windows/native/libawt/windows/awt_MenuItem.cpp#L563
30-08-2023

Reassigned after discussing with [~rmahajan]
30-08-2023

There's a duplicate bug of this: JDK-8310641. It confirms the menu implementation doesn't support High DPI environment.
25-08-2023

Need to switch to a higher priority bug. Will start work on it after that.
09-08-2023

I have preproduced the issue and I see the menu items on right clicking the tray icon as not spaced properly. Also the checkmarks of the menu items look crooked. This is with 225% scaling on my Windows 10 machine.
07-08-2023

Does a regular popup menu (right-click menu) scale correctly? Does the menu bar scale correctly? Do the popup menus in menu bar scale correctly?
04-08-2023

It's similar to JDK-8255439 but it's not duplicate because of the wrong menu behaviour.
10-03-2022

Additional information from submitter: ============================= I'm attaching six screenshots of TrayIconDemo taken on Windows scaled at 100% and at 175% with sun.java2d.uiScale set to 2, 3 or missing (TrayIconDemo-*.png). The name of each file should tell you which settings were used when they were taken. I'm also attaching a screenshot of the tray icon of Fanurio (the application that I'm working on) taken on Windows scaled at 300% (Fanurio-windowsScale-300p-java2d-uiScale-missing.png). To make the menu readable, I added a separator after each menu entry in the main tray icon menu but this is not ideal. You can see that the selected menu entry (Start New Timer) has a narrow blue rectangle and that the menu items of its submenu are crowded just like they are in TrayIconDemo-windowsScale-100p-java2d-uiScale-3.png and TrayIconDemo-windowsScale-175p-java2d-uiScale-3.png. Also, there should be a small arrow icon in the blue rectangle to indicate that Start New Timer has a submenu but it is not visible. This problem is especially visible when the scaling factor is large (for instance 300%).
01-02-2021

Additional Information from submitter: =========================== This issue is not a duplicate of JDK-8255439. It reports a problem with the tray icon menu, not with the tray icon image.
25-01-2021

Duplicate of JDK-8255439
18-01-2021