Get effective screen size from Java

GraphicsEnvironment has a method which returns the maximum available size, accounting all taskbars etc. no matter where they are aligned:

GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds()

Note: On multi-monitor systems, getMaximumWindowBounds() returns the bounds of the entire display area. To get the usable bounds of a single display, use GraphicsConfiguration.getBounds() and Toolkit.getScreenInsets() as shown in other answers.

Leave a Comment