This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes How do i know if a JFrame is iconified? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How do i know if a JFrame is iconified?" Watch "How do i know if a JFrame is iconified?" New topic

How do i know if a JFrame is iconified?

Sarone Thach
Ranch Hand

Joined: Jun 25, 2003
Posts: 89
Hi there!
could someone please tell me how I can check if my JFrame is either fully iconified or fully maximised or in full display.
The reason I ask this is because when I run my test program on a MacOS X (10.3.2 JKD 1.4.2)platform, minising and maximising, the program hangs. I think it is something to do with me trying to deconifing the frame, when it has not yet been completely iconified. But then again it can be my code, if you spot the a bug, please let me know.
Confused, read the code it might make some sense.
If it is absolutely impossible, please tell me, so I can stop searching for answers and get some sleep.
Jason Steele
Ranch Hand

Joined: Apr 25, 2003
Posts: 100
I believe this is what you want:

if(frame.getExtendedState() == frame.ICONIFIED) { // do stuff }
if(frame.getExtendedState() == frame.MAXIMIZED_BOTH) { // do stuff }

An egg is a chicken's house!
Sarone Thach
Ranch Hand

Joined: Jun 25, 2003
Posts: 89
Hmm, you did answer the orginal question.
It's still hanging. My theory has been proven wrong. Any one got ideas.....
Nathan Pruett

Joined: Oct 18, 2000
Posts: 4121

Does the program hang right off? Or does it run for a while before exibiting the problem? I don't have an OS X machine to test it on, but I ran it on a Win2K box for about a minute and it didn't lock up. It may just be an issue that popping the frame up and down just uses too many resources (i.e. redrawing the frame, dealing with native frames, etc.)... see if the program works if you slow the thread down (besides... it currently goes so fast it isn't usable anyway...).

Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Sarone Thach
Ranch Hand

Joined: Jun 25, 2003
Posts: 89
Yeah I speed it up, because it would take too long to hang otherwise.
I was issolationg a problem in my application, to prove that the hang was not due to my code, but to the popping and unpopping the frame.
It does not hang on the windows platform. Only the MacOS. I thought someone might have some idea why this is, so I can fix it in my application. Or perhaps, my code for popping and unpopping is wrong.
I am compiling the code in JBuilder9 on Windows, then running it on the Mac, I wonder if that makes a difference.
I agree. Here's the link:
subject: How do i know if a JFrame is iconified?
It's not a secret anymore!