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 / General / January 2006

Tip: Looking for answers? Try searching our database.

fitting Jframe size to the screen

Thread view: 
Gali - 18 Jan 2006 14:48 GMT
Hello everyone,
I have a question about fitting the size of a Jframe to the screen. i
have an application that has some Jframes, and when i use these
commands:
frame.pack();
frame.setVisible(true);
I can fit the frame to my current screen - but the problem is that it
gets so big that I can't see the buttom status bar (on windows) which
tells me which frames are open. if i use setPrefferedSize() or
setMaximalSize() they make my Jframe size limited which dose not fit
to all types of resolution, and i wish it to be flexible.

Thank you very much in advance,
Gali.
Oliver Wong - 18 Jan 2006 15:28 GMT
> Hello everyone,
> I have a question about fitting the size of a Jframe to the screen. i
[quoted text clipped - 7 lines]
> setMaximalSize() they make my Jframe size limited which dose not fit
> to all types of resolution, and i wish it to be flexible.

   Did you try having the JFrame maximized? I believe on Windows OSes, a
maximized window will not cover up the taskbar.

   - Oliver
Knute Johnson - 18 Jan 2006 18:09 GMT
>>Hello everyone,
>>I have a question about fitting the size of a Jframe to the screen. i
[quoted text clipped - 12 lines]
>
>     - Oliver

Gail:

Oliver is correct, if you maximise a frame (in XP anyway) it will not
over write the taskbar.  The problem with it is that it will be as wide
as the screen.  There really is no good solution to your problem that I
have found under windows.  You would put the contents of your window
into a ScrollPane if it gets too big.  After you pack() you could take
the size and compare that with the screen size from the Toolkit and call
setSize on your frame.  All options are kludgy.

Signature

Knute Johnson
email s/nospam/knute/

atom - 18 Jan 2006 21:29 GMT
frame.setExtendedState(MAXIMIZED_BOTH);

you'll also need

import javax.swing.JFrame;
Thomas Hawtin - 18 Jan 2006 22:28 GMT
> Hello everyone,
> I have a question about fitting the size of a Jframe to the screen. i
[quoted text clipped - 7 lines]
> setMaximalSize() they make my Jframe size limited which dose not fit
> to all types of resolution, and i wish it to be flexible.

You should not rely upon the windows status bar being at the bottom of
the screen, or upon its size.

To get the usable area of the screen, see:

http://download.java.net/jdk6/docs/api/java/awt/GraphicsEnvironment.html#getMaxi
mumWindowBounds
()

On UNIX there is a bug that prevents windows from opening initially
maximised.

Tom Hawtin
Signature

Unemployed English Java programmer
http://jroller.com/page/tackline/

Gali - 22 Jan 2006 21:01 GMT
Thank you all,
The Toolkit class has this command :
abstract  Dimension getScreenSize()
which returns the size of the screen in Dimention type (like 768/1024)
so i can fit my frames to any resoluion, with the help of a simple
function.
Gali.


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.