How one can get the screen resolution where a swing jFrame app is running?
+3
A:
This call will give you the information you want.
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Starkey
2010-09-09 20:15:36
+3
A:
You can get the screen size with the Toolkit.getScreenSize()
method.
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
double width = screenSize.getWidth();
double height = screenSize.getHeight();
On 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 screen resolution in DPI you'll have to use the getScreenResolution()
method on Toolkit
.
Resources :
Colin Hebert
2010-09-09 20:15:55
A:
int resolution =Toolkit.getDefaultToolkit().getScreenResolution();
System.out.println(resolution);
Eric W
2010-09-09 20:17:18