Alex Rivera | Logout

How do you get the screen width in java?

Asked 2009-12-20T18:40:10.857
44

Does anyone know how you would get the screen width in java? I read something about some toolkit method but I'm not quite sure what that is.

Thanks, Andrew

Edit
Report

2 Answers

79
java.awt.Toolkit.getDefaultToolkit().getScreenSize()
answered 2009-12-20T18:43:22.423
17

The working area is the desktop area of the display, excluding taskbars, docked windows, and docked tool bars.

If what you want is the "working area" of the screen, use this:

public static int GetScreenWorkingWidth() {
    return java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().width;
}

public static int GetScreenWorkingHeight() {
    return java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().height;
}
answered 2011-11-11T23:52:31.343

Your Answer