java - 将 jre 从 8u201 切换到 8u211 时如何修复 java 应用程序尺寸?

标签 java swing user-interface swingbuilder

所以我正在开发这个 java swing 应用程序,该应用程序当前在 Java 8 更新 192 上运行。

在此更新中它工作正常,但是当我将 java 版本升级到 8 update 211 时,它似乎更改了应用程序的 UI,因此一切看起来都更大,切换这些版本后没有进行任何代码更改。

有人知道这个问题有什么好的解决办法吗?

两个图像的相对比例相同,因此后图像更大,图标分辨率较低。

之前:

enter image description here

之后: enter image description here

最佳答案

https://www.oracle.com/java/technologies/javase/8u211-relnotes.html

您可以看到:

High DPI Auto-Scaling on Windows

If the Windows desktop DPI of the default screen is configured via Display Settings to be 150% or greater (that is 144 dpi or greater), JDK will now ask Windows to auto-scale the entire UI of a Java application to be consistent with the rest of the Windows desktop UI.

Below that value Java applications will appear at the same size as they did in previous releases.

This threshold is chosen as a trade-off between compatibility and legibility of the UI. At higher DPI settings, without this auto-scaling, the Java UI may be just too small to be read comfortably.

There may be some negative consequences such as

  • Some elements of the UI may appear somewhat blurry, particularly if the scaling factor is a non-integral value (that is 1.5 rather than 2.0).

  • ClearType text is not effective when auto-scaling so grey scale anti-aliasing is used instead by the Swing toolkit.

  • Window sizing and positioning calculations may be adversely affected.

In the event that the negative consequences outweigh the benefits, an application can request the old behaviour by specifying:

-Dsun.java2d.dpiaware=true

Conversely, if the application would prefer to be auto-scaled even at lower DPI settings, then specify:

-Dsun.java2d.dpiaware=false

In the absence of either explicit setting, the default behaviour described above will apply.

JDK-8204512 (not public)

core-libs/java.lang

关于java - 将 jre 从 8u201 切换到 8u211 时如何修复 java 应用程序尺寸?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73724180/

相关文章:

java - 使用 JpaPagingItemReader 时无法获取基于不同 pageSize 和 ChunkSize 的所有记录

java - 为什么Android中有这么多内部类?

java - AWT-EventQueue-0“StackOverflowError

java - MigLayout:尝试全屏时仅显示窗口

java - JTextPane 不断抛出 BadLocation

java - Firebase 检查值

java - Maven POM 中的 ejb-client 类型是什么?

c++ - PySide 中的多线程 Boost Python C++ 代码

JavaFX 仅使用调试和断点更新图形

javascript - 应用阴影的最佳方式是什么?