Get effective screen size from Java

后端 未结 4 771
清酒与你
清酒与你 2020-11-30 03:28

I would like to get the effective screen size. That is: the size of the screen without the taskbar (or the equivalent on Linux/Mac).

I am currently using...

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-30 03:48

    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.

提交回复
热议问题