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 / April 2006

Tip: Looking for answers? Try searching our database.

JDesktopPane getAllFrames() method when minimizing

Thread view: 
dan.goyette@gmail.com - 14 Apr 2006 19:01 GMT
I've designing a simple GUI based on the idea of a Desktop with various
JInternalFrame components. One thing I'd like to keep track of is which
internal frames are in the Desktop at any given time.

I noticed the getAllFrames() method, which seems to work well. It gives
me a list of internal frames, on which I can call getName() to identify
which frames are present.

The problem is this: If I minimize any of the internal frames, the
getAllFrames() method still returns those frames in its list. However,
if I try to call getName() on an internal frame that is minimized,
getName() returns null. If I maximize the internal frame it then
getName() will return its name again.

Can anyone tell me what I'm doing wrong? I'm using Java 1.5. Does a
minimized JInternalFrame get transformed into some other kind of object
when it's minimized?

Thanks,
-Dan
Thomas Hawtin - 14 Apr 2006 18:43 GMT
> The problem is this: If I minimize any of the internal frames, the
> getAllFrames() method still returns those frames in its list. However,
[quoted text clipped - 5 lines]
> minimized JInternalFrame get transformed into some other kind of object
> when it's minimized?

You can't transform an object from one type into another (but see the
strategy pattern). What I believe happens during minimisation is that
the JInternalFrame is removed and replaced by its matching
JInternalFrame.JDesktopIcon. JDesktopPane.getAllFrames looks as if it
returns all the internal frames, whether they are minimised or not.

As a complete guess, you are not calling getName on a minimised
JInternalFrame, but on its JInternalFrame.JDesktopIcon. Possibly through
JDesktopPane.getComponents or similar.

You can easily see what a component is by dumping either it or its class
and hashCode to System.err. You can see the whole window's contents by
pressing shift-control-F1.

I would tend to keep track of components though a mechanism other than
name. Name works okay if each child component is different. For instance
a Look & Feel managing the subcomponents of a JComboBox. But for general
use, I'd avoid.

Tom Hawtin
Signature

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

dan.goyette@gmail.com - 15 Apr 2006 06:00 GMT
Your guess was right no. After doing a bit of getClass() printing it
turns out that when the JInternalFrame is minimized getClass() returns
"JInternalFrame$JDesktopIcon". Thanks for the intuition.

I know the Javadoc for JDesktopIcon advises not to use the API for
JDesktopIcon, however I'm planning to use one method, getInternalFrame,
such that I can still access the original JInternalFrame even if it
happens to be minimized.

Thanks for you help.

-Dan


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.