Doubt about screen height

Hello, everybody!

To set the size of the main window of my application I use the following code:

Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

setSize(screenSize.width, screenSize.height);

That's working very well. But is there a way that I can subtract from the height

of the window the height of the program bar (that one that in Windows has the

Start button), to get something like screenSize.height - programBarHeight? It

doesn't matter for me if I can get this with some trick, but I just would like

that the solution was platform independent.

Thank you very much.

[654 byte] By [MarcosAntonioPS] at [2007-9-30 21:24:17]
# 1

Use the Frame class's setExtendedState method. This method will take the task bar (or any other docable toolbar) into account when maximizing the frame. For example:

JFrame frame = new JFrame();

frame.setExtendedState(Frame.MAXIMIZED_BOTH);

paternostro at 2007-7-7 2:56:21 > top of Java-index,Administration Tools,Sun Connection...
# 2
Is there a way to do that not maximizing the window, just adjusting the width and height?
MarcosAntonioPS at 2007-7-7 2:56:21 > top of Java-index,Administration Tools,Sun Connection...
# 3
Not unless you want to use the JNI to call native code. I don't see the problem with the maximized window as that's the proper state if you desire the window to be sized to the screen's dimensions less the dockable toolbars.
paternostro at 2007-7-7 2:56:21 > top of Java-index,Administration Tools,Sun Connection...
# 4
I just would like that the user had the chance to change the window position without having to restore it before, as the window is maximized. Anyway I'll consider your solution.Thank you again.
MarcosAntonioPS at 2007-7-7 2:56:21 > top of Java-index,Administration Tools,Sun Connection...