mgarin / weblaf

WebLaF is a fully open-source Look & Feel and component library written in pure Java for cross-platform desktop Swing applications.
http://weblookandfeel.com
GNU General Public License v3.0
1.13k stars 234 forks source link

"Tiny" / scaled down decorated frame on Windows #629

Open kirill-grouchnikov opened 4 years ago

kirill-grouchnikov commented 4 years ago
public class QuickStart {
    public static void main(final String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                JFrame.setDefaultLookAndFeelDecorated(true);
                WebLookAndFeel.install();

                JFrame frame = new JFrame("Mine");
                frame.setLayout(new BorderLayout());
                frame.add(new JButton("here!"));

                frame.pack();
                frame.setLocationRelativeTo(null);
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.setVisible(true);
            }
        });
    }
}

Running this on Java 9.0.4 on a Windows 10 laptop with a high-resolution screen (resolution 3480x2160, default scale of 250%) results in a really tiny, scaled down frame.

Commenting out the JFrame.setDefaultLookAndFeelDecorated(true); line creates a correctly sized frame. The same for commenting out the WebLookAndFeel.install(); line - which creates a decorated Metal frame.

This is under the latest 1.2.12 release of WebLaf. Note that there have been changes in the later versions of the JDK / JRE for system-level scaling of content. I think that was in version 11.

kirill-grouchnikov commented 4 years ago

Found https://bugs.openjdk.java.net/browse/JDK-8180815 that says that the window scaling should work on JDK 9, but it's not working on my machine.

kirill-grouchnikov commented 4 years ago

Changing from JFrame to WebFrame fixes the issue, FWIW.

mgarin commented 4 years ago

I know that there are certainly some issues with scaling but unfortunately I don't have a single high-resolution screen to test any of them right now.

Also, this:

Changing from JFrame to WebFrame fixes the issue, FWIW.

Is actually weird, because there should be no difference between how custom decoration is rendered on either. Unless there is some JDK issue that WebFrame or the custom root pane component fixes unintentionally?

mgarin commented 4 years ago

Overall - I'll need to take a proper look at how scaling works on different JDK and OS versions because there are certainly some differences (probably even different implementations) which also have some weird interactions with custom window decoration.

lwahonen commented 4 years ago

FYI you can test things on a low-resolution screen, just change Windows DPI settings to 250% and make sure all the elements are now uniformly huge. If something looks reasonably sized on a normal screen at 250%, it will look tiny on a high DPI screen. This has saved my bacon in the past, and seemed so obvious once I realized it.

mgarin commented 4 years ago

I know that you can manually change OS scaling to check it on low-resolution screens - it would work for testing issues with scaling. But it's still best to test things out on an actually high-resolution screen to see if resulting UI would actually looks reasonable or not on specific resolution/scaling.