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 / GUI / May 2005

Tip: Looking for answers? Try searching our database.

DesktopManager implementation question

Thread view: 
Laird Nelson - 24 May 2005 19:10 GMT
Before I go reinventing the wheel, does anyone know of a pointer to a
DesktopManager implementation that handles resizing properly when its
internal frames are minimized?

Specifically, I'm looking for some set of behavior equal to or greater
than the following:

   When an internal frame is iconified AND the look and feel has
located that iconified frame at the bottom of the desktop AND the
desktop is resized, THEN the iconified frame should reoccupy the
appropriate position in the newly-sized desktop.

Right now what happens is that the iconified frame simply stays where it
is.  This is in keeping with a container that really doesn't have a
layout manager, but it's not what a user would expect.

Thanks in advance for any pointers; I have done my homework via Google,
this newsgroup, etc. but haven't found anything.  There are plenty of
examples of putting a JDesktopPane into a JScrollPane, but for various
reasons I'd really REALLY like to avoid this if possible.

Thanks,
Laird
Laird Nelson - 24 May 2005 21:16 GMT
> Before I go reinventing the wheel, does anyone know of a pointer to a
> DesktopManager implementation that handles resizing properly when its
> internal frames are minimized?

Not finding any such pointer, I discovered a clean hack to do what I want.

For those who are interested:

* Add a ComponentListener to the JDesktopPane that detects when it has
been resized.
* Get all of its internal frames via its getAllFrames() method.
* For each of those frames THAT IS AN ICON, tell a grievous lie by
putting the following client property into it:

  "wasIconOnce", "false"

This is a lie.  It clearly WAS an icon once--actually it IS, right at
this very moment when we're looking at it.  But note that it is the
evaluation of this property that causes the DefaultDesktopManager to
decide whether it needs to recompute the location/bounds for the
DesktopIcon.  So we're effectively tricking the DesktopManager into
recomputing the bounds on a resize.  Note that the very first thing that
the DefaultDesktopManager does at line 143 is reset the "wasIconOnce"
property to TRUE, so when we're all done we haven't touched the state of
things at all.
* Call desktopPane.getDesktopManager().iconifyFrame(frameInQuestion);

Works like a charm.  Those who want a marginally less hackish approach
will override the DesktopManager's wasIcon(JInternalFrame) method instead.

Best,
Laird


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.