I help maintain a large, very old Swing project. We noticed that the swing project pages running under JRE 11 look quite a bit different from the swing project running under JRE 8, our previous version.
I have been exploring this issue. One thing I noticed is that basic sizing seems to be different. JRE11 makes all the JFrames larger. We need to have the sizing stay consistent.
Here is a small program to demonstrate what I am seeing:
import javax.swing.*;
public class JustAFrame
{
public static void main(String[] args)
{
SwingUtilities.invokeLater(
() -> {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation( WindowConstants.EXIT_ON_CLOSE );
frame.pack();
frame.setSize(400, 500);
frame.setVisible(true);
});
}
}
I ran this program on the same Windows 10 machine using java 64 bit version jdk1.8.0_241 and zulu11.41.23-ca-fx-jdk11.0.8-win_x64. I'm attaching an image showing the same class running in the two java versions side by side. The JRE 11 version appears to be about 50% larger. What can I do to make the JRE 11 JVM make our JFrames the size as our previous version of java, without having to go into every JFrame instance in our application and fiddling with the size Dimension parameter?