Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable scaling the UI on Windows, for Java 9 applications?

There was no proper HiDPI support in Java 8.

In Java 9, JavaFx applications correctly scale to the monitor they are in. For example, if my monitor is set to scale at 150%, the Java application is scaled to 150%.

See: http://openjdk.java.net/jeps/263

However, for testing purposes, I need to be able to disable scaling by using java.exe flags, in Windows 10. How can I achieve this?

Also, maybe I can disable (and re-enable) this programmatically within the application itself?

like image 844
MarcG Avatar asked Dec 02 '17 21:12

MarcG


3 Answers

Use

System.setProperty( "sun.java2d.uiScale", "1.0" );

in your java code, that worked for me (JDK 17).

like image 159
cyborck Avatar answered Oct 23 '22 00:10

cyborck


if needed, found another couple of helpful JVM parameters from that website :

-Dsun.java2d.uiScale.enabled=false
-Dsun.java2d.win.uiScaleX=1.0 -Dsun.java2d.win.uiScaleY=1.0
like image 32
Jeremie Avatar answered Oct 22 '22 22:10

Jeremie


I found this obscure option in a substance bug report. This fixes the issue for Swing applications.

-Dsun.java2d.uiScale=1.0

If you're using JavaFX you'll need

-Dprism.allowhidpi=false

Unfortunately I cannot find official documentation for either of these options

like image 20
Adam Avatar answered Oct 22 '22 22:10

Adam