Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / November 2003

Tip: Looking for answers? Try searching our database.

How do I query the system for the maximum screen size in pixels?

Thread view: 
Chuck Fuller - 01 Nov 2003 23:16 GMT
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
David Kurtz - 02 Nov 2003 00:19 GMT
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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.