Can I set the DPI resolution of my Java Swing application without changing the systems' DPI setting?

前端 未结 3 1949
忘掉有多难
忘掉有多难 2021-02-07 21:21

I have a Java application using the Substance LookAndFeel with Windows as the the target platform and I want to increase the DPI setting of my application without chang

3条回答
  •  攒了一身酷
    2021-02-07 21:51

    Yes you can, but you need to run it on JRE 9.

    This is because the Java runtime declared itself to be "DPI-aware" but didn't really supported it for AWT and Swing. Java applications were sized and rendered based on pixels rather than being properly scaled, this included HiDPI displays. Anyways, this has been recently solved. See the issue JEP 263: HiDPI Graphics on Windows and Linux and the upgrade.

    So, increasing the font size does not work (because it does not increase the rest of the things); the jvm argument -Dsun.java2d.dpiaware=false does not work (because it was not really supported); and the manifest file + registry edit (for Windows) just does not work.

    Solution: You need to run it on JRE 9 because it really supports this feature.

提交回复
热议问题