• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Sliding Panels

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...

-Nate
 
Steve Knight
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Doh! So simple.
Thanks,
Steve
 
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic