void (boolean collapse) { try { if (collapse) { if (myIsInitialized) remove(myContent); } else { add(myContent, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); } myIsCollapsed = collapse; Icon icon = getIcon(); if (icon != null){ myToggleCollapseButton.setIcon(icon); myToggleCollapseButton.setBorder(null); myToggleCollapseButton.setBorderPainted(false); myToggleCollapseButton.setToolTipText(getToggleButtonToolTipText()); } if (collapse) { setFocused(true); setSelected(true); } else { myContent.requestFocusInWindow(); } notifyListeners(); revalidate(); repaint(); } finally { myIsInitialized = true; } }