Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the real usable resolution

With

Toolkit.getDefaultToolkit().getScreenSize()

I get the screen size.

But usually this isn't the available size I have for my own program, because on the mac there is a menubar on top and on the bottom an iconbar. Windows also has an iconbar. So how do I get the real available space?

like image 483
Christian Avatar asked Sep 16 '10 14:09

Christian


2 Answers

From Java forum:

UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
Rectangle bounds = ge.getMaximumWindowBounds();

Now you have the bounds sans platform-dependent desktop decorations. I don't have a Mac around so I only verified that it works on WinXP/JDK6.

Note that if you auto-hide taskbar, the bounds do NOT include taskbar, which is correct.

like image 65
Geoffrey Zheng Avatar answered Oct 03 '22 05:10

Geoffrey Zheng


I'm not sure if this will work, but try the GraphicsConfiguration/GraphicsDevice instead. You might not be able to get a bounding box that discount the dock on OS X since the area of the dock is still considered screen space. I can move windows on top of it. I can also move the dock to be on the side and not at the bottom of the screen (same goes for the Windows task bar).

http://download.oracle.com/javase/6/docs/api/java/awt/GraphicsDevice.html

like image 31
Matti Lyra Avatar answered Oct 03 '22 05:10

Matti Lyra