Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Maximize a frame

Status
Not open for further replies.

aryajur

Programmer
Jul 2, 2003
45
US
I was making this GUI with the AWT package. I cannot find a way to dreate a Frame and display it on the screen in a Maximized form. Please can anybody help me with this. I want to know how u can create a Frame inherited class and display the frame on the screen in the maximised form.
I tried using getMaximumSize() and then setSize() but this does not get the maximized form, it however gets the same size.

 
You can get the screen dimensions like this:

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

this.setWidth(screen.width);
this.setHeight(screen.height);

You might have to reduce the height a bit on a Windows desktop to allow for the task bar.
 
Idarke's way is the best you can do for the moment.
A few remarks : This has not the same effect as pressing the maximize button : The frame will occupy the whole screen, but it is not "maximized" :
- It has still the maximize button in its caption bar and can be "maximized" by this button.
- You can still drag the Frame around.

You can also code idarke's method in one line :
Code:
this.setSize(Toolkit.getDefaultToolkit().getScreenSize());
 
Thank you,
So that means there is no way to get the window appear as if already maximized, all we can do is give it the maximum size ! If there is no way I guess I would have to manage with this.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top