JFrame scaling in Java 9
Asked Answered
R

1

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);
    }
}
Reames answered 5/2, 2018 at 12:33 Comment(3)
you could try this. might be just the scalingTopology
@Topology Thanks, unfortunately our lovely IT department have disabled such magic.Reames
Similar post #47613506Ifill
R
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

Reames answered 5/2, 2018 at 12:51 Comment(2)
Could you clarify if that option is there by default and if so, what the value is?Topology
@Topology I would do if I could find any official documentation on it :)Reames

© 2022 - 2024 — McMap. All rights reserved.