Adjust display of an application independent of monitor resolution

0

I made a Java application and realized that when it runs on a computer with a higher resolution, it gets smaller. How to adjust display of an application independent of monitor resolution?

    
asked by anonymous 03.06.2015 / 17:06

1 answer

1

You can get the screen size with the Toolkit.getScreenSize() method.

Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
double width = screenSize.getWidth();
double height = screenSize.getHeight();

In a multi-monitor configuration you should use this:

GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
int width = gd.getDisplayMode().getWidth();
int height = gd.getDisplayMode().getHeight();

If you want to get the DPI resolution you can use the getScreenResolution() method of the Toolkit class.

References:
javadoc - Toolkit.getScreenSize ()
On Linux a bug may occur has a fix here ! Home Good Luck!

    
03.06.2015 / 18:21