'Java font size changes from win 10 to win 11
We have a large Java application that looks fine with Win 10. When we test it on Win 11, about 1/2 the controls have a much smaller font than the others.
This is using the same version of the Open JDK Java 11 VM on both machines.
My searches haven't found anything, but it seems odd that it would only be our Java app with this issue.
At one time I did have a tool that let me just click on a java application window/control and see all the information about it (colors, font size, etc..). That was years ago, and I can't seem to find one that does that now.
Any ideas on why some fonts would change size on Win 11?
Solution 1:[1]
Since we don't have time to figure out a change for the L&F, we just added a little hack to force a different default Font. We added the following as the first thing in our main().
javax.swing.plaf.FontUIResource f = new FontUIResource(new Font(FONT_NAME, Font.PLAIN, size));
java.util.Enumeration<Object> keys = UIManager.getDefaults().keys();
while (keys.hasMoreElements()) {
Object key = keys.nextElement();
Object value = UIManager.get(key);
if (value instanceof javax.swing.plaf.FontUIResource) {
UIManager.put(key, f);
}
}
Now all the controls that we were NOT forcing the font on, look good and aren't stupidly small.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | CasaDelGato |