public class JCollapsiblePanel extends JPanel
JPanel shows a Component with a headline above it. The user can click on
the headline in order to collapse or exand the component. If the component is
collapsed, it will be hidden and only the headline is shown. If the component is
expanded, everything is shown.
JCollapsiblePanel can be used to allow the user to hide unimportant parts of
the GUI if there is only little space available.
Due to a bug this component was not really functional until R12.
JPanel.AccessibleJPanelJComponent.AccessibleJComponentContainer.AccessibleAWTContainerComponent.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy| Modifier and Type | Field and Description |
|---|---|
protected Component |
content |
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWaccessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH| Constructor and Description |
|---|
JCollapsiblePanel()
Creates an empty
JCollapsiblePanel with no title. |
JCollapsiblePanel(String title)
Creates an empty
JCollapsiblePanel with the given title. |
JCollapsiblePanel(String title,
Component comp)
Creates a
JCollapsiblePanel with the given title and Component. |
JCollapsiblePanel(String title,
Component comp,
boolean expanded)
Creates a
JCollapsiblePanel with the given title and Component,
using the given expanded state initially. |
JCollapsiblePanel(String title,
Component comp,
boolean expanded,
String id)
Creates a
JCollapsiblePanel with the given title and Component,
using the given expanded state initially. |
| Modifier and Type | Method and Description |
|---|---|
void |
addChangeListener(ChangeListener l)
Adds a
ChangeListener. |
Icon |
getCollapsedIcon()
Gets the current icon to be used if the component is collapsed.
|
Component |
getContent()
Gets the current content
Component. |
Icon |
getExpandedIcon()
Gets the current icon to be used if the component is expanded.
|
String |
getTitle()
Gets the current title above the component.
|
boolean |
isExpanded()
Gets the current expanded state.
|
void |
removeChangeListener(ChangeListener l)
Removes a
ChangeListener. |
void |
setCollapsedIcon(Icon icon)
Sets the icon to be used in the title if the component is collapsed.
|
void |
setContent(Component comp)
Sets a new content
Component. |
void |
setEnabled(boolean b)
Sets the enabled state.
|
void |
setExpanded(boolean b)
Sets the expanded state.
|
void |
setExpandedIcon(Icon icon)
Sets the icon to be used in the title if the component is expanded.
|
void |
setTitle(String title)
Sets the title above the component.
|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIaddAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateadd, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeaction, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCyclepublic JCollapsiblePanel()
JCollapsiblePanel with no title.public JCollapsiblePanel(String title)
JCollapsiblePanel with the given title.public JCollapsiblePanel(String title, Component comp)
JCollapsiblePanel with the given title and Component. The
panel is initially expanded.title - Titlecomp - Component to be used as contentpublic JCollapsiblePanel(String title, Component comp, boolean expanded)
JCollapsiblePanel with the given title and Component,
using the given expanded state initially.title - Titlecomp - Component to be used as contentexpanded - Initial state, true: expanded, false: collapsedpublic JCollapsiblePanel(String title, Component comp, boolean expanded, String id)
JCollapsiblePanel with the given title and Component,
using the given expanded state initially.
With the given id, the collapse state is remembered for the next time the application is started. If there is no state remembered, the given default "expanded" state will be used instead.
title - Titlecomp - Component to be used as contentexpanded - Initial state, true: expanded, false: collapsedid - Unique identifier to remember the collapse state. Pass null if
the state shall not be remembered.public void setCollapsedIcon(Icon icon)
icon - New icon to be usedpublic Icon getCollapsedIcon()
public void setExpandedIcon(Icon icon)
icon - New icon to be usedpublic Icon getExpandedIcon()
public void setEnabled(boolean b)
JCollapsiblePanel will only disable
the title button, but not the content. I.e. the user cannot collapse the component,
but can still use it.
NOTE: if setEnabled(boolean) is set to false while the
panel is collapsed, then the user will be unable to expand and use the component.
setEnabled in class JComponentpublic void setExpanded(boolean b)
true, the Component will be shown. If
false, the Component will be hidden.public boolean isExpanded()
public void setContent(Component comp)
Component. It will replace the current content.public Component getContent()
Component.Component, or null if none was set.public void addChangeListener(ChangeListener l)
ChangeListener. It will be invoked when the collapsed/expanded state
was changed.l - ChangeListener to be addedpublic void removeChangeListener(ChangeListener l)
ChangeListener.l - ChangeListener to be removedCopyright © 2004–2016. All rights reserved.