JFrame scaling in Java 9

Adam :

Exactly the same code running under Java 9u4 on the left and 8u144 on the right on Windows 7.

different window sizes

Java 9 seems to making the window larger. What is causing this - JEP 263? How can I disable it?

public class SimpleFrame {
    public static void main(String[] args) {
        JFrame frame = new JFrame();
        frame.getContentPane().add(new JLabel("Horse"));
        frame.setSize(new Dimension(200, 100));
        frame.setVisible(true);
    }
}
Adam :

I found this obscure option in a substance bug report. This fixes the issue for Swing applications.

-Dsun.java2d.uiScale=1.0

If you're using JavaFX you'll need

-Dprism.allowhidpi=false

Unfortunately I cannot find official documentation for either of these options

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=430466&siteId=1