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...
component.getGraphicsConfiguration().getBounds()
...and subtracting the default taskbar size depending on the OS, but I would like a way that works even if the user has resized/moved the taskbar.
Here is the code I ended up using:
This could determine the screen size in pixels without the taskbar
EDIT
Can someone please run this code on Xx_nix and Mac OSX and check if JDialog is really placed in the bottom right corner?
GraphicsEnvironment has a method which returns the maximum available size, accounting all taskbars etc. no matter where they are aligned:
Note: On multi-monitor systems,
getMaximumWindowBounds()
returns the bounds of the entire display area. To get the usable bounds of a single display, useGraphicsConfiguration.getBounds()
andToolkit.getScreenInsets()
as shown in other answers.Here's a method I wrote to quickly do the calculations by subtracting the margins and centering it in the screen.