This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Swing Window States Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Swing Window States" Watch "Swing Window States" New topic

Swing Window States

Ender Valencia

Joined: Jun 03, 2008
Posts: 4
Hey everyone,

I wrote some code to override the JFrame's minimize event, but I am not sure it is the best it could be.

The part I know could be better is the == 1. Is there a constant I can compare to to tell that the JFrame is minimized? What is the proper way to tell if a JFrame is minimzed/maximized.

Also, once it is minimized, how can I force it to maximize/restore?

Pavan Kumar Srinivasan

Joined: Sep 17, 2008
Posts: 27
Using Frame's get/set extendedState method ,it would be possible .

More info can be found at Frame docs
Rob Spoor

Joined: Oct 27, 2005
Posts: 19651

You should look at java.awt.Frame for the constants; in this case Frame.ICONIFIED.

For setting the new state there is method setExtendedState that takes these values as well - Frame.NORMAL, Frame.ICONIFIED, Frame.MAXIMIZED_HORIZ, Frame.MAXIMIZED_VERT and Frame.MAXIMIZED_BOTH.

How To Ask Questions How To Answer Questions
Ender Valencia

Joined: Jun 03, 2008
Posts: 4

I had a feeling Iconified was the one I needed, but wasn't sure based on the name.

I have it working just fine now. I minimize to the system tray and then maxmize from the tray.
I agree. Here's the link:
subject: Swing Window States
Similar Threads
being notified of screen resolution changes
java version problem 1.3 to 1.4.1_03
version problem??for plots
java and swing
close JFrame