The Source for Java Technology Collaboration

Home » java.net Forums » Java Tools » Java Development Tools

Thread: Request for feedback: implementing Swing-based drawers

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
This question is not answered. Helpful answers available: 2. Correct answers available: 1.

Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 2 - Last Post: Sep 7, 2007 9:35 AM by: javaguy44
mspetrovic

Posts: 4
Request for feedback: implementing Swing-based drawers
Posted: Sep 6, 2007 10:19 AM
 
  Click to reply to this thread Reply

Good day.

I've inherited some code to which I need to add a 'dresser drawer' like functionality. Click on a logical 'open' button and the drawer opens, revealing, or displaying as the case may be, a JPanel with more stuff in it. Click on a logical 'close' button and the drawer closes, leaving its container in the visual state in which it started. A familiar example of this effect might be something like the Mac Dock in 'auto hide' mode, where the Dock moves in and out of sight and addressability with some pointer action. The Dock is always 'there', but sometimes just not visible. So it would be with the drawer.

I am wondering if a solution would be based loosely on theDrawer.setVisible(), or whether something that sets the drawer's component width or height to 0 for-hide would be more likely.

Can anyone offer guidance on how to approach this using standard Swing techniques?

Thanks.

invalidname

Posts: 64
Re: Request for feedback: implementing Swing-based drawers
Posted: Sep 7, 2007 7:18 AM   in response to: mspetrovic
 
  Click to reply to this thread Reply

I actually banged on this for a week or so while working on Swing Hacks before abandoning it as impractical, at least with my approach. What I thought to do was to have a JWindow (which is a top-level container but doesn't have the decorations of a JFrame or JDialog) that I would manually manage in relation to the JFrame that it seemed to come "out" of. What burned me was a lack of Z-order controllability -- with focus on the window, it would then be above the JFrame, potentially cutting off the side of its frame (particularly bad if you want to animate the "slide out"). I also found it impractical to move the child window with the parent frame... listening for changes to the parent's bounds, some JVM's and OS's would give me continuous events during a move or resize, others wouldn't. Without continuous updates, moving the frame would basically detach it from the drawer until the move was complete, at which point the drawer would get one resize event and snap into position. I came to believe I couldn't come up with something that wouldn't a) take 10 pages of hacky-ass code in the book, and b) suck anyways. And we were on a tough schedule, so I cut it.

javaguy44

Posts: 3
Re: Request for feedback: implementing Swing-based drawers
Posted: Sep 7, 2007 9:35 AM   in response to: mspetrovic
 
  Click to reply to this thread Reply

Take a look at JXCollapsiblePane in swingx

or it's original component the JCollapsiblePane in l2fprod

HTH




 XML java.net RSS