Class CollapsibleSection

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class CollapsibleSection extends JPanel
A collapsible section with a clickable header that toggles content visibility.

The header shows an arrow indicator and title. Clicking anywhere on the header toggles the content panel. Suitable for grouping related settings or information in scrollable panels.

Usage:


 CollapsibleSection section = new CollapsibleSection("Advanced Settings", false);
 section.addContent(myTextField);
 section.addContent(myCheckBox);
 parentPanel.add(section);
 
  • Constructor Details

    • CollapsibleSection

      public CollapsibleSection(String title, boolean expanded)
      Creates a collapsible section.
      Parameters:
      title - the header text
      expanded - whether the section starts expanded
  • Method Details

    • getContent

      public JPanel getContent()
      Returns the content panel for direct manipulation.
    • addContent

      public void addContent(Component component)
      Adds a component to the content area.
    • setExpanded

      public void setExpanded(boolean expanded)
      Sets the expanded state.
    • isExpanded

      public boolean isExpanded()
      Returns whether the section is currently expanded.