views:

42

answers:

2

Hello,

with

Toolkit.getDefaultToolkit().getScreenSize()

i do geht the screen size.

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

+1  A: 

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

Matti
My answer is just one tiny step forward from this.
Geoffrey Zheng
+1  A: 

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.

Geoffrey Zheng
yes thank you, this works perfekt.On Mac OSX, also.
Christian
I'd appreciate if you can accept the answer, then.
Geoffrey Zheng