package bcgTree.gui;

import java.awt.BorderLayout;
import java.awt.Component;

import javax.swing.Action;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.UIManager;

import org.jdesktop.swingx.JXCollapsiblePane;

public class Accordion extends JPanel {
	private static final long serialVersionUID = 1L;
	private String title;
	private Component comp;

	public Accordion(String title, Component comp){
		this.title = title;
		this.comp = comp;
		initGUI();
	}
	
	private void initGUI(){
		this.setLayout(new BorderLayout());
		JXCollapsiblePane collapsiblePane = new JXCollapsiblePane();
		collapsiblePane.add(comp);
		// get the built-in toggle action
		Action toggleAction = collapsiblePane.getActionMap().get(JXCollapsiblePane.TOGGLE_ACTION);
		// use the collapse/expand icons from the JTree UI
		toggleAction.putValue(JXCollapsiblePane.COLLAPSE_ICON, UIManager.getIcon("Tree.expandedIcon"));
		toggleAction.putValue(JXCollapsiblePane.EXPAND_ICON, UIManager.getIcon("Tree.collapsedIcon"));
		JButton col = new JButton(collapsiblePane.getActionMap().get(JXCollapsiblePane.TOGGLE_ACTION));
		col.setText(this.title);
		this.add(col, BorderLayout.NORTH);
		this.add(collapsiblePane, BorderLayout.CENTER);
	}
}

@@ -45,16 +45,39 @@
 Layout;%0A
+import java.awt.Color;%0A
 import j
@@ -95,16 +95,16 @@
 ponent;%0A
-
 %0Aimport 
@@ -207,16 +207,54 @@
 Manager;
+%0Aimport javax.swing.border.LineBorder;
 %0A%0Aimport
@@ -697,16 +697,106 @@
 (comp);%0A
+%09%09collapsiblePane.setCollapsed(true);%0A%09%09this.setBorder(new LineBorder(Color.LIGHT_GRAY));%0A
 %09%09// get
@@ -1164,16 +1164,16 @@
 con%22));%0A
-
 %09%09JButto
@@ -1262,16 +1262,60 @@
 TION));%0A
+%09%09col.setHorizontalAlignment(JButton.LEFT);%0A
 %09%09col.se

Improve accordion layout