Well, to get the screen size, you would use
Toolkit.getDefaultToolkit().getScreenSize()
That being said, if you are using 1.4 or later, you should set your window
size by calling
setExtendedState(JFrame.MAXIMIZED_BOTH)
on your frame. This has the benefit of allowing for a taskbar or similar
device taking up space on the screen, which simply setting your preferred
size based on the screen size would not do.
Of course, you should verifiy that the toolkit for your system supports this
by calling
Toolkit.getDefaultToolkit().isFrameStateSupported(JFrame.MAXIMIZED_BOTH)
first, since if, for some reason, this operation is not supported, your
frame will not resize.
Dave
> I want to create a GUI that is always maximized, but how do I query
> the system for the maximum screen size so that I can set the
> preferredSize to that size?
>
> Thanks
> Chuck
Tor Iver Wilhelmsen - 02 Nov 2003 10:28 GMT
> Toolkit.getDefaultToolkit().getScreenSize()
For multi-monitor setups he should perhaps use the getToolkit() of the
component rendered on the screen he wants the sizes of, though.