JDK-8154551 : HiDPI Ubuntu Unity 16 and SystemTray icon
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 9
  • Priority: P3
  • Status: Closed
  • Resolution: Not an Issue
  • Submitted: 2016-04-19
  • Updated: 2017-01-12
  • Resolved: 2017-01-12
Related Reports
Relates :  
Relates :  
Description
I have a machine with HiDPI display and Ubuntu 15.10 installed.
Setting the scaling factor to 1, I run the following simple test:
import java.awt.*;
import java.awt.image.BufferedImage;

public class TryTray {
    static TrayIcon icon;
    public static void main(String args[]) throws Exception {
        if (! SystemTray.isSupported()) {
            System.out.println("tray is not supported");
            return;
        }
        SystemTray tray = SystemTray.getSystemTray();
        icon = new TrayIcon(new BufferedImage(20, 20, BufferedImage.TYPE_INT_RGB), "Bimm Bomm");
        tray.add(icon);
    }
}

It works as expected: a black square of an icon is painted in the tray area.
Now set the factor to 2 and rerun the test: no icon is visible any more.

Running the test like java/awt/TrayIcon/TrayIconEvents/TrayIconEventsTest.java I'm getting the coordinates of the icon. Having the screen width 3000, it reports some 2500 but doesn't paint anything visible.


Comments
It looks like a Unity panel bug since the location of the embedded frame is set to outside the screen bounds.
03-11-2016

https://bugs.launchpad.net/ubuntu/+source/unity/+bug/1638667
02-11-2016

The issue is reprodicible for Ubuntu 16.04 as well (so updating the summary). HiDPI display was used. When scale factor = 1 (using "Scale for menu and title bars" ruler), the icon is visible. While changing the factor up to 2, it decreases in size and then vanishes. Please try also to run the test and then to change the scale while the icon is visible - some artifacts occur (see the screenshot - the icon's color was changed to red for more contrast)
14-06-2016

Setting -Dsun.java2d.uiScale=2 and/or GDK_SCALE=2 doesn't help. Note also that adding Robot robot = new Robot(); robot.mouseMove(2500, 100); one may see that mouse pointer moves to a correct location without -Dsun.java2d.uiScale=2 but to the rightmost edge of the screen with the flag set. Update: now I understand that it is expected behavior of the robot since the screen is logically 1/2 of the original width.
20-04-2016