fitting Jframe size to the screen

G

Gali

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.
 
O

Oliver Wong

Gali said:
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.

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

- Oliver
 
K

Knute Johnson

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

- 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.
 
T

Thomas Hawtin

Gali said:
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.

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#getMaximumWindowBounds()

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

Tom Hawtin
 
G

Gali

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top