19

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
  • 35,919
  • 9
  • 100
  • 137
  • 1
    you could try [this](https://superuser.com/questions/988379/how-do-i-run-java-apps-upscaled-on-a-high-dpi-display/1207925#1207925). might be just the scaling – XtremeBaumer Feb 05 '18 at 12:45
  • @XtremeBaumer Thanks, unfortunately our lovely IT department have disabled such magic. – Adam Feb 05 '18 at 12:46
  • Similar post https://stackoverflow.com/questions/47613006/how-to-disable-scaling-the-ui-on-windows-for-java-9-applications – Naman Feb 05 '18 at 14:13

1 Answers1

13

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

Adam
  • 35,919
  • 9
  • 100
  • 137