Exactly the same code running under Java 9u4 on the left and 8u144 on the right on Windows 7.
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);
}
}
By default, we can minimize a JFrame by clicking on minimize button and maximize a JFrame by clicking on maximize button at the top-right position of the screen. We can also do programmatically by using setState(JFrame. ICONIFIED) to minimize a JFrame and setState(JFrame. MAXIMIZED_BOTH) to maximize a JFrame.
getScreenSize(); // get 2/3 of the height, and 2/3 of the width int height = screenSize. height * 2 / 3; int width = screenSize. width * 2 / 3; // set the jframe height and width jframe. setPreferredSize(new Dimension(width, height));
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With