tags:

views:

47

answers:

2

In my app I'm using swing and awt. I am setting the size (and position) of the window I'm creating based on toolkit.getScreenSize() and this works fine. But I would like to deal with the size of the windows 7 task bar at the bottom (or wherever) of the screen. I can not seem to find out how to do this. Anyone know how I can get the size if the task bar?

+3  A: 

You'll want to look at java.awt.GraphicsEnvironment#getMaximumWindowBounds(), which returns the bounds of the screen area excluding the area covered by "objects in the native windowing system such as task bars and menu bars".

Matthew Wightman
A: 

Per Matthew's post I got going down the right path. I was able to determine the windows bounds of the task bar with:

Insets scnMax = getToolkit().getScreenInsets(getGraphicsConfiguration());
taskBarSize = scnMax.bottom;

and then subtracting that value from a getScreenSize() height value to help me position the app window correctly.

Don't have a multi monitor system so I'm not sure how this works there but I will have to test that out.

pn1 dude
Additionally what I look for is a value greater than zero in any of the scnMax.top, scnMax.bottom, scnMax.right, and scnMax.left and then adjust accordingly.
pn1 dude