Class ExpandCollapseOptions

java.lang.Object
ca.corbett.extras.actionpanel.ActionPanelOptions
ca.corbett.extras.actionpanel.ExpandCollapseOptions

public class ExpandCollapseOptions extends ActionPanelOptions
Encapsulates all expand/collapse related options for an ActionPanel, including animation options.

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

      public ExpandCollapseOptions setExpandable(boolean allow)
      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

      public ExpandCollapseOptions setAnimationEnabled(boolean animationEnabled)
      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

      public ExpandCollapseOptions setAnimationDurationMs(int animationDurationMs)
      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

      public ExpandCollapseOptions setAllowHeaderDoubleClick(boolean allow)
      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.