How to have Collapsable/Expandable JPanel in Java Swing

Nayan Soni picture Nayan Soni · Nov 18, 2011 · Viewed 16.3k times · Source

I want a JPanel that can be Collapsed or Expanded when user clicks on a text/icon on its border. I need this type of panel due to space crunch in my application.

I read about CollapsiblePanel class but not sure how to use it.. I think SwingX is needed to be downloaded but did not find that anywhere.

Moreover, it would be better if I get the solution to this in basic Java Swing.

Answer

kleopatra picture kleopatra · Nov 18, 2011

not sure where you looked, but it's not that difficult to find - even given the infrastructure mess we are in ;-)

Go to the project home of SwingX, then follow the link in the first paragraph to the (barebone) download section, down to releases\1.6.2. Nothing special to the collapsibles themselves, just containers to put components into.