Collapse « JPanel « Java Swing Q&A





1. How to have Collapsable/Expandable JPanel in Java Swing    stackoverflow.com

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 ...

2. Expand/Collapse Panels    coderanch.com

import java.awt.*; import java.awt.event.*; import java.awt.font.*; import java.awt.image.BufferedImage; import javax.swing.*; public class ExpandingPanels extends MouseAdapter { ActionPanel[] aps; JPanel[] panels; public ExpandingPanels() { assembleActionPanels(); assemblePanels(); } public void mousePressed(MouseEvent e) { ActionPanel ap = (ActionPanel)e.getSource(); if(ap.target.contains(e.getPoint())) { ap.toggleSelection(); togglePanelVisibility(ap); } } private void togglePanelVisibility(ActionPanel ap) { int index = getPanelIndex(ap); if(panels[index].isShowing()) panels[index].setVisible(false); else panels[index].setVisible(true); ap.getParent().validate(); } private int getPanelIndex(ActionPanel ap) { ...

4. JPanel to collapse    coderanch.com

I am working on it, but what I struggle with is to put the CheckBox in the TiledBorder. This is what I have, do you have an additional hint: JPanel filter = new JPanel(new GridBagLayout()); JCheckBox filterActivation1 = new JCheckBox(); filter.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.BLACK), "Filter"); To: Darryl Burke Tabbed Pane is not applicable for this scenario, since I need to be able to show ...