Does anyone know how to implement a panel that slides out from the side of a frame when you click a button or something. I want something similar to how IntelliJ's IDEA does it (for those that know IDEA). Thanks, Steve
Just make a panel with 2 sides (BorderLayout.EAST and BorderLayout.WEST) and call setVisible( false ) on the component on the side that you want to toggle. Then, put a JButton( or JLabel ) on the other side and add a mouse ( or action ) listener to it to call setVisible( true ) on the component that is hidden.
The one thing that I found was tricky was hiding the component again after the mouse left the area. I tried adding a mouselistener and using mouseExited(), but the exit event doesn't always get thrown ( This may be due to the fact that the component that I was toggling was a drag source for Drag and drop events... this may have interfered with the normal mouse listener... ), so I had to add a mouse listener to the component containing the top panel... this ended up being the content pane of the JFrame everything was in... and testing for the state of the panels and the location of the mouse...
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
I don't know if it fits your scenario, but you could also use a JSplitPane which gives you the option to collapse and reopen each side of the pane. JSplitPanes can be vertical or horizontal and have a bunch of other options as well. Just a thought.
Wait a minute, I'm trying to think of something clever to say...<p>Joel
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com