Class ExpandCollapseOptions
You can control whether the user is allowed to expand/collapse action groups at all using
setExpandable(boolean allow). When disallowed, the user will not be able to
expand/collapse groups, and all groups will be forced to be expanded. Note that programmatic
expand/collapse via setExpanded() is always allowed regardless of this setting.
You can optionally allow double-clicking on the group header label to toggle the expanded/collapsed
state of the group, in addition to the provided expand/collapse toggle button.
Double-clicking is disabled by default, but can be enabled with setAllowHeaderDoubleClick(true).
Animation - by default, expand/collapse operations are animated with a smooth sliding effect.
The default animation duration is 200ms. You can customize the animation speed using
setAnimationDurationMs(int ms), or disable animation entirely with
setAnimationEnabled(false) to revert to instantaneous expand/collapse.
Note that programmatically calling setExpanded() will always expand/collapse instantly, without animation.
This class only exists to relieve some clutter from the ActionPanel class, which is getting quite large.
- Since:
- swing-extras 2.8
- Author:
- scorbo2
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final int -
Method Summary
Modifier and TypeMethodDescriptionintReturns the duration of the expand/collapse animation in milliseconds.booleanReports whether double-clicking on the group header label is allowed to toggle the expanded/collapsed state of the group.booleanReturns whether animation is enabled for expand/collapse operations.booleanReports whether the user is allowed to expand/collapse action groups.setAllowHeaderDoubleClick(boolean allow) Allows or disallows double-clicking on the group header label to toggle the expanded/collapsed state of the group.setAnimationDurationMs(int animationDurationMs) Sets the duration of the expand/collapse animation in milliseconds.setAnimationEnabled(boolean animationEnabled) Sets whether animation is enabled for expand/collapse operations.setExpandable(boolean allow) Allows or disallows the user to expand/collapse action groups.Methods inherited from class ca.corbett.extras.actionpanel.ActionPanelOptions
addListener, fireOptionsChanged, removeListener
-
Field Details
-
DEFAULT_ANIMATION_DURATION_MS
public static final int DEFAULT_ANIMATION_DURATION_MS- See Also:
-
ANIMATION_FRAME_DELAY_MS
public static final int ANIMATION_FRAME_DELAY_MS- See Also:
-
-
Method Details
-
setExpandable
Allows or disallows the user to expand/collapse action groups. By default, this is allowed. Note that programmatic expand/collapse via setExpanded() is always allowed regardless of this setting.- Parameters:
allow- True to allow expand/collapse, false to disallow.- Returns:
- This ExpandCollapseOptions instance, for method chaining.
-
isExpandable
public boolean isExpandable()Reports whether the user is allowed to expand/collapse action groups.- Returns:
- True if expand/collapse is allowed, false otherwise.
-
isAnimationEnabled
public boolean isAnimationEnabled()Returns whether animation is enabled for expand/collapse operations.- Returns:
- True if animation is enabled, false otherwise.
-
setAnimationEnabled
Sets whether animation is enabled for expand/collapse operations. When disabled, groups will expand and collapse instantaneously.- Parameters:
animationEnabled- True to enable animation, false to disable it.- Returns:
- This ExpandCollapseOptions instance, for method chaining.
-
getAnimationDurationMs
public int getAnimationDurationMs()Returns the duration of the expand/collapse animation in milliseconds.- Returns:
- The animation duration in milliseconds.
-
setAnimationDurationMs
Sets the duration of the expand/collapse animation in milliseconds. The default is 200ms. A longer duration will result in a slower animation.- Parameters:
animationDurationMs- The animation duration in milliseconds. Must be greater than 0.- Returns:
- This ExpandCollapseOptions instance, for method chaining.
-
setAllowHeaderDoubleClick
Allows or disallows double-clicking on the group header label to toggle the expanded/collapsed state of the group. By default, this is disabled.- Parameters:
allow- True to allow double-clicking on the header to toggle expand/collapse.- Returns:
- This ExpandCollapseOptions instance, for method chaining.
-
isAllowHeaderDoubleClick
public boolean isAllowHeaderDoubleClick()Reports whether double-clicking on the group header label is allowed to toggle the expanded/collapsed state of the group.- Returns:
- True if double-clicking on the header toggles expand/collapse, false otherwise.
-