how to create collapsible and expandable panel in Java Swing?

Alex Michael Raj picture Alex Michael Raj · Nov 25, 2013 · Viewed 8.7k times · Source

I need to create a collapsible and expandable panel in Java Swing.. I am not able to find it in the DESIGN PALETTE of Netbeans 7.4 .. Kindly help me

Answer

An SO User picture An SO User · Nov 25, 2013

JavaFX has a JFXPanel class which allows you to embed JavaFX components in Swing. Using that, you can embed the TitledPane and Accordion controls into your Swing application.

Your end result will be like this:
enter image description here

This is exactly what you need, isn't it ? =)
This saves you a lot of coding work.

Tutorial on how to work with these JavaFX components is here: http://docs.oracle.com/javafx/2/ui_controls/accordion-titledpane.htm and
embedding of JavaFX nodes in Swing is here: How to add JFXPanel to already existing swing app