Possible Duplicate:
Screen resolution java
Hi,
How can I get screen resolution in Java?
You can use AWT Toolkit,
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
double width = screenSize.getWidth();
double height = screenSize.getHeight();
or better java2d, which supports multi monitor setups:
GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
int width = gd.getDisplayMode().getWidth();
int height = gd.getDisplayMode().getHeight();
You can determine the screen resolution (screen size) using the Toolkit class. This method call returns the screen resolution in pixels, and stores the results in a Dimension object, as shown here:
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
You can then get the screen width and height as int's by directly accessing the width and height fields of the Dimension class, like this:
screenHeight = screenSize.height;
screenWidth = screenSize.width;
check this
another method
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