Class CollapsableTitledBorder
java.lang.Object
javax.swing.border.AbstractBorder
javax.swing.border.TitledBorder
com.everdro1d.libs.swing.components.CollapsableTitledBorder
- All Implemented Interfaces:
Serializable
,Border
A collapsable titled border for JPanels and JTabbedPanes.
If using a JTabbedPane and you want to get the expanded status, implement a method like below.
private boolean isOSTabbedPaneExpanded() { return !(osTabbedPane.getTabComponentAt(0) instanceof JLabel); }
- See Also:
-
Field Summary
Fields inherited from class javax.swing.border.TitledBorder
ABOVE_BOTTOM, ABOVE_TOP, BELOW_BOTTOM, BELOW_TOP, border, BOTTOM, CENTER, DEFAULT_JUSTIFICATION, DEFAULT_POSITION, EDGE_SPACING, LEADING, LEFT, RIGHT, TEXT_INSET_H, TEXT_SPACING, title, titleColor, titleFont, titleJustification, titlePosition, TOP, TRAILING
-
Constructor Summary
ConstructorsConstructorDescriptionCollapsableTitledBorder
(JComponent panel, String titleText, boolean expandedDefault, boolean exclusive, int panelExpandedHeight) Creates a collapsable titled border for a JPanel or JTabbedPane.CollapsableTitledBorder
(JComponent panel, String titleText, boolean expandedDefault, boolean exclusive, int panelExpandedHeight, boolean showTabbedPaneSeparators) Creates a collapsable titled border for a JPanel or JTabbedPane.CollapsableTitledBorder
(JComponent panel, String titleText, boolean expandedDefault, boolean exclusive, int panelExpandedHeight, int panelCollapsedHeight) Creates a collapsable titled border for a JPanel or JTabbedPane.CollapsableTitledBorder
(JComponent panel, String titleText, boolean expandedDefault, boolean exclusive, int panelExpandedHeight, int panelCollapsedHeight, boolean showTabbedPaneSeparators) Creates a collapsable titled border for a JPanel or JTabbedPane.CollapsableTitledBorder
(JComponent panel, String titleText, boolean expandedDefault, boolean exclusive, int panelExpandedHeight, int panelCollapsedHeight, Consumer<JTabbedPane> tabbedPaneExpandFunc, boolean showTabbedPaneSeparators) Creates a collapsable titled border for a JPanel or JTabbedPane.CollapsableTitledBorder
(JComponent panel, String titleText, boolean expandedDefault, boolean exclusive, int panelExpandedHeight, Consumer<JTabbedPane> tabbedPaneExpandFunc) Creates a collapsable titled border for a JPanel or JTabbedPane.CollapsableTitledBorder
(JComponent panel, String titleText, boolean expandedDefault, boolean exclusive, int panelExpandedHeight, Consumer<JTabbedPane> tabbedPaneExpandFunc, boolean showTabbedPaneSeparators) Creates a collapsable titled border for a JPanel or JTabbedPane. -
Method Summary
Methods inherited from class javax.swing.border.TitledBorder
getBaseline, getBaselineResizeBehavior, getBorder, getBorderInsets, getFont, getMinimumSize, getTitle, getTitleColor, getTitleFont, getTitleJustification, getTitlePosition, isBorderOpaque, paintBorder, setBorder, setTitle, setTitleColor, setTitleFont, setTitleJustification, setTitlePosition
Methods inherited from class javax.swing.border.AbstractBorder
getBorderInsets, getInteriorRectangle, getInteriorRectangle
-
Constructor Details
-
CollapsableTitledBorder
public CollapsableTitledBorder(JComponent panel, String titleText, boolean expandedDefault, boolean exclusive, int panelExpandedHeight, boolean showTabbedPaneSeparators) Creates a collapsable titled border for a JPanel or JTabbedPane.Default params set to:
panelCollapsedHeight = 50
- Parameters:
panel
- the panel to add the border totitleText
- the text to display in the titleexpandedDefault
- true if the panel should be expanded by defaultexclusive
- true if only one panel can be expanded at a timepanelExpandedHeight
- the height of the panel when expandedshowTabbedPaneSeparators
- true if the tabbed pane separators should be shown when expanded
-
CollapsableTitledBorder
public CollapsableTitledBorder(JComponent panel, String titleText, boolean expandedDefault, boolean exclusive, int panelExpandedHeight, int panelCollapsedHeight, boolean showTabbedPaneSeparators) Creates a collapsable titled border for a JPanel or JTabbedPane.Default params set to:
tabbedPaneExpandFunc = null
- Parameters:
panel
- the panel to add the border totitleText
- the text to display in the titleexpandedDefault
- true if the panel should be expanded by defaultexclusive
- true if only one panel can be expanded at a timepanelExpandedHeight
- the height of the panel when expandedpanelCollapsedHeight
- the height of the panel when collapsedshowTabbedPaneSeparators
- true if the tabbed pane separators should be shown when expanded
-
CollapsableTitledBorder
public CollapsableTitledBorder(JComponent panel, String titleText, boolean expandedDefault, boolean exclusive, int panelExpandedHeight, Consumer<JTabbedPane> tabbedPaneExpandFunc, boolean showTabbedPaneSeparators) Creates a collapsable titled border for a JPanel or JTabbedPane.Default params set to:
panelCollapsedHeight = 50
- Parameters:
panel
- the panel to add the border totitleText
- the text to display in the titleexpandedDefault
- true if the panel should be expanded by defaultexclusive
- true if only one panel can be expanded at a timepanelExpandedHeight
- the height of the panel when expandedtabbedPaneExpandFunc
- a function to call when the tabbed pane is expandedshowTabbedPaneSeparators
- true if the tabbed pane separators should be shown when expanded
-
CollapsableTitledBorder
public CollapsableTitledBorder(JComponent panel, String titleText, boolean expandedDefault, boolean exclusive, int panelExpandedHeight) Creates a collapsable titled border for a JPanel or JTabbedPane.Default params set to:
panelCollapsedHeight = 50 tabbedPaneExpandFunc = null showTabbedPaneSeparators = false
- Parameters:
panel
- the panel to add the border totitleText
- the text to display in the titleexpandedDefault
- true if the panel should be expanded by defaultexclusive
- true if only one panel can be expanded at a timepanelExpandedHeight
- the height of the panel when expanded
-
CollapsableTitledBorder
public CollapsableTitledBorder(JComponent panel, String titleText, boolean expandedDefault, boolean exclusive, int panelExpandedHeight, int panelCollapsedHeight) Creates a collapsable titled border for a JPanel or JTabbedPane.Default params set to:
tabbedPaneExpandFunc = null showTabbedPaneSeparators = false
- Parameters:
panel
- the panel to add the border totitleText
- the text to display in the titleexpandedDefault
- true if the panel should be expanded by defaultexclusive
- true if only one panel can be expanded at a timepanelExpandedHeight
- the height of the panel when expandedpanelCollapsedHeight
- the height of the panel when collapsed
-
CollapsableTitledBorder
public CollapsableTitledBorder(JComponent panel, String titleText, boolean expandedDefault, boolean exclusive, int panelExpandedHeight, Consumer<JTabbedPane> tabbedPaneExpandFunc) Creates a collapsable titled border for a JPanel or JTabbedPane.Default params set to:
panelCollapsedHeight = 50 showTabbedPaneSeparators = false
- Parameters:
panel
- the panel to add the border totitleText
- the text to display in the titleexpandedDefault
- true if the panel should be expanded by defaultexclusive
- true if only one panel can be expanded at a timepanelExpandedHeight
- the height of the panel when expandedtabbedPaneExpandFunc
- a function to call when the tabbed pane is expanded
-
CollapsableTitledBorder
public CollapsableTitledBorder(JComponent panel, String titleText, boolean expandedDefault, boolean exclusive, int panelExpandedHeight, int panelCollapsedHeight, Consumer<JTabbedPane> tabbedPaneExpandFunc, boolean showTabbedPaneSeparators) Creates a collapsable titled border for a JPanel or JTabbedPane.- Parameters:
panel
- the panel to add the border totitleText
- the text to display in the titleexpandedDefault
- true if the panel should be expanded by defaultexclusive
- true if only one panel can be expanded at a timepanelExpandedHeight
- the height of the panel when expandedpanelCollapsedHeight
- the height of the panel when collapsedtabbedPaneExpandFunc
- a function to call when the tabbed pane is expandedshowTabbedPaneSeparators
- true if the tabbed pane separators should be shown when expanded
-