While porting my projects to Java SE 9 I noticed that the JavaFX team has slipped in some small but important changes concerning DPI scaling that appear to be only documented in the Java bug database, specifically JDK Bug 8091832.
- The entry for 2016-03-31 notes that the startup flag
-Dglass.win.minHiDPI, defining the minimum display DPI setting for full (not just font-only) JavaFX DPI scaling, has been removed as it conflicted with per-monitor DPI support.
- The same entry notes that the startup flag
-Dglass.win.uiScaleis still supported, so you could use
-Dglass.win.uiScale=125%to force full JavaFX DPI scaling at 120 DPI (= 125%) where JavaFX used to only scale fonts, even after Java SE 8u60.
- However, an entry for 2016-04-06 states that a “fix brings the rest of the graphics into line with the font size” at 120 DPI, meaning that setting is no longer special-cased and now receives full DPI scaling too. No startup flag should be necessary anymore.
- We can finally determine the current DPI scaling, in both the Screen class (
getOutputScaleX/Y) and the Window class (
- Even better, the Window class got writable scaling properties (
forceIntegerRenderScale) so you can override DPI scaling on a per-window basis. (The similar
glass.winstartup flags were removed, as noted in the entry for 2016-03-31).
Note — This feature is unfortunately less useful than I had hoped for. See the comments for an explanation.
- Unrelated to the linked bug, the
min/maxHeightproperties of the Stage class are now correctly DPI-scaled, so you can properly use them to restrict window resizing.
Very good news! Some older blog posts I wrote on these subjects are now happily obsolete, namely JavaFX GUI Scaling at 120-144 DPI and parts of JavaFX and JAVA_TOOL_OPTIONS. I’m not sure if the mentioned flag
-Dprism.order=sw to force software rendering still works, but so far I haven’t seen anything to the contrary.