Getting the Screen Size

// Get the size of the default screen Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
If more than one screen is available, this example gets the size of each screen:
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gs = ge.getScreenDevices(); // Get size of each screen for (int i=0; i<gs.length; i++) { DisplayMode dm = gs[i].getDisplayMode(); int screenWidth = dm.getWidth(); int screenHeight = dm.getHeight(); }

Comments

6 Jan 2010 - 11:58am by Anonymous (not verified)

after days and weeks and looking for some type of example, I finally got my code working thanks to this snippet!

Post a comment

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.