Package swingtree
Class UIForSplitButton<B extends JSplitButton>
java.lang.Object
- Type Parameters:
B- The type ofJSplitButtonthat thisUIForSplitButtonis configuring.
public final class UIForSplitButton<B extends JSplitButton>
extends UIForAnyButton<UIForSplitButton<B>,B>
A SwingTree builder node designed for configuring
JSplitButton instances.-
Method Summary
Modifier and TypeMethodDescriptionprotected UIForSplitButton<B> _newBuilderWithState(swingtree.BuilderState<B> newState) An internal wither method which creates a new builder instance with the providedBuilderStatestored inside it.protected swingtree.BuilderState<B> _state()Returns the state of the builder, which is a container for the wrapped component as well as it's type and currentEventProcessor.Use this to add aJMenuItemto theJSplitButtonpopup menu.<I extends JMenuItem>
UIForSplitButton<B> Use this to add aSplitItemto theJSplitButtonpopup menu.<M extends JMenuItem>
UIForSplitButton<B> add(UIForMenuItem<M> forItem) Use this to add aJMenuItemto theJSplitButtonpopup menu.onButtonClick(sprouts.Action<SplitItemDelegate<JMenuItem>> action) Use this as an alternative toonClick(Action)to register a button click action with an action lambda having access to a delegate with more context information including not only the currentJSplitButtoninstance, but also the currently selectedJMenuItemand a list of all other items.onCancel(sprouts.Action<ComponentDelegate<B, PopupMenuEvent>> action) Registers a listener to be notified when the split button options drop down popup is canceled, which typically happens when the user clicks outside the popup menu.onClick(sprouts.Action<ComponentDelegate<B, ActionEvent>> action) Use this to register a basic action for when theJSplitButtonbutton is being clicked (not the split part).onClose(sprouts.Action<ComponentDelegate<B, PopupMenuEvent>> action) Registers a listener to be notified when the split button is closed, meaning its popup menu is hidden after the user clicks on the split button drop down button.onOpen(sprouts.Action<ComponentDelegate<B, PopupMenuEvent>> action) Registers a listener to be notified when the split button is opened, meaning its popup menu is shown after the user clicks on the split button drop down button.onSelection(sprouts.Action<SplitButtonDelegate<JMenuItem>> action) Actions registered here will be called when the user selects aJMenuItemfrom the popup menu of thisJSplitButton.onSplitClick(sprouts.Action<SplitButtonDelegate<JMenuItem>> action) Actions registered here will be called when the split part of theJSplitButtonwas clicked.<E extends Enum<E>>
UIForSplitButton<B> withSelection(sprouts.Var<E> selection) Use this to buildJSplitButtons where the selectable options are represented by anEnumtype.<E extends Enum<E>>
UIForSplitButton<B> withSelection(sprouts.Var<E> selection, Function<E, String> textProvider) Use this to buildJSplitButtons where the selectable options are represented by anEnumtype.<E extends Enum<E>>
UIForSplitButton<B> withSelection(sprouts.Var<E> selection, sprouts.Event clickEvent) Use this to buildJSplitButtons where the selectable options are represented by anEnumtype, and the click event is handles by anEventinstance.<E extends Enum<E>>
UIForSplitButton<B> withSelection(sprouts.Var<E> selection, sprouts.Event clickEvent, Function<E, String> textProvider) Allows you to buildJSplitButtons where the selectable options are represented by anEnumtype, and the click event is handled by anEventinstance as well as a "text provider", which is a function that maps an enum value to a string to be used as the button text displayed to the user.Methods inherited from class swingtree.UIForAnyButton
_onChange, _onClick, _onModelChange, isBorderPaintedIf, isBorderPaintedIf, isPressedIf, isSelectedIf, isSelectedIf, isSelectedIf, isSelectedIf, isSelectedIfNot, isSelectedIfNot, isSelectedIfNot, makePlain, onChange, withButtonGroup, withFont, withFont, withHorizontalAlignment, withHorizontalAlignment, withHorizontalTextAlignment, withHorizontalTextAlignment, withIcon, withIcon, withIcon, withIcon, withIcon, withIcon, withIcon, withIcon, withIconOnDisabled, withIconOnDisabled, withIconOnDisabled, withIconOnDisabled, withIconOnDisabled, withIconOnDisabled, withIconOnDisabled, withIconOnDisabled, withIconOnDisabledAndSelected, withIconOnDisabledAndSelected, withIconOnDisabledAndSelected, withIconOnDisabledAndSelected, withIconOnDisabledAndSelected, withIconOnDisabledAndSelected, withIconOnDisabledAndSelected, withIconOnDisabledAndSelected, withIconOnHover, withIconOnHover, withIconOnHover, withIconOnHover, withIconOnHover, withIconOnHover, withIconOnHover, withIconOnHover, withIconOnHoverAndSelected, withIconOnHoverAndSelected, withIconOnHoverAndSelected, withIconOnHoverAndSelected, withIconOnHoverAndSelected, withIconOnHoverAndSelected, withIconOnHoverAndSelected, withIconOnHoverAndSelected, withIconOnPress, withIconOnPress, withIconOnPress, withIconOnPress, withIconOnPress, withIconOnPress, withIconOnPress, withIconOnPress, withIconOnSelected, withIconOnSelected, withIconOnSelected, withIconOnSelected, withIconOnSelected, withIconOnSelected, withIconOnSelected, withIconOnSelected, withMargin, withMargin, withText, withText, withVerticalAlignment, withVerticalAlignment, withVerticalTextAlignment, withVerticalTextAlignmentMethods inherited from class swingtree.UIForAnySwing
_addComponentTo, _addViewableProps, _addViewableProps, _addViewableProps, _isUndefinedColor, _isUndefinedFont, _setBackground, _setEnabled, _setMinHeight, _setMinWidth, _setPrefWidth, _tryCalculatingDiffBetween, add, add, add, add, add, add, add, add, add, add, addAll, addAll, addAll, addAll, addAll, addAll, addAll, addAll, addAll, addAll, addAll, addAll, doUpdates, group, group, id, id, isEnabledIf, isEnabledIf, isEnabledIf, isEnabledIfNot, isEnabledIfNot, isEnabledIfNot, isFocusableIf, isFocusableIf, isFocusableIf, isFocusableIfNot, isFocusableIfNot, isFocusableIfNot, isValidIf, isVisibleIf, isVisibleIf, isVisibleIf, isVisibleIfNot, isVisibleIfNot, isVisibleIfNot, makeFocused, makeNonOpaque, makeOpaque, on, on, onCharTyped, onFocusGain, onFocusLoss, onHidden, onKeyPress, onKeyRelease, onKeyTyped, onMouseClick, onMouseDrag, onMouseEnter, onMouseEnter, onMouseEnterGreedy, onMouseExit, onMouseExit, onMouseExitGreedy, onMouseMove, onMousePress, onMouseRelease, onMouseWheelDown, onMouseWheelMove, onMouseWheelUp, onMoved, onPressed, onRelease, onResize, onShown, onTyped, onTyped, onView, withBackground, withBackground, withBackgroundColor, withBackgroundIf, withBackgroundIf, withBackgroundIf, withBackgroundIf, withBorder, withBorder, withBorderTitled, withBorderTitled, withBoxLayout, withCompoundBorder, withCompoundBorderTitled, withCursor, withCursor, withCursorIf, withCursorIf, withDragAway, withDropSite, withEmptyBorder, withEmptyBorder, withEmptyBorder, withEmptyBorder, withEmptyBorderTitled, withEmptyBorderTitled, withEmptyBorderTitled, withEmptyBorderTitled, withEmptyBorderTitled, withEmptyBorderTitled, withEmptyBorderTitled, withEmptyBorderTitled, withFlowLayout, withFlowLayout, withFlowLayout, withFontSize, withFontSize, withForeground, withForeground, withForegroundColor, withForegroundIf, withForegroundIf, withForegroundIf, withForegroundIf, withGridBagLayout, withGridLayout, withGridLayout, withGridLayout, withHeight, withHeight, withHeightExactly, withHeightExactly, withLayout, withLayout, withLayout, withLayout, withLayout, withLayout, withLayout, withLayout, withLayout, withLayout, withLayout, withLayout, withLineBorder, withLineBorder, withLineBorder, withLineBorderTitled, withLineBorderTitled, withLineBorderTitled, withLineBorderTitled, withMatteBorder, withMatteBorder, withMatteBorder, withMatteBorderTitled, withMatteBorderTitled, withMatteBorderTitled, withMaxHeight, withMaxHeight, withMaxSize, withMaxSize, withMaxSize, withMaxSize, withMaxSize, withMaxWidth, withMaxWidth, withMinHeight, withMinHeight, withMinSize, withMinSize, withMinSize, withMinSize, withMinSize, withMinWidth, withMinWidth, withPrefHeight, withPrefHeight, withPrefSize, withPrefSize, withPrefSize, withPrefSize, withPrefSize, withPrefWidth, withPrefWidth, withProperty, withRepaintOn, withRepaintOn, withRepaintOn, withRepaintOn, withRepaintOn, withRepaintOn, withRepaintOn, withRepaintOn, withRoundedLineBorder, withRoundedLineBorder, withRoundedLineBorder, withRoundedLineBorder, withRoundedLineBorderTitled, withRoundedLineBorderTitled, withRoundedLineBorderTitled, withRoundedLineBorderTitled, withRoundedLineBorderTitled, withRoundedLineBorderTitled, withRoundedLineBorderTitled, withSize, withSize, withSize, withSize, withSizeExactly, withSizeExactly, withSizeExactly, withSizeExactly, withStyle, withTooltip, withTooltip, withTransitionalStyle, withTransitoryStyle, withWidth, withWidth, withWidthExactly, withWidthExactlyMethods inherited from class swingtree.UIForAnything
_addBuildersTo, _addBuilderTo, _addComponentsTo, _disposeState, _onShow, _onShow, _onShowDelegated, _runInApp, _runInApp, _runInUI, _this, _with, _withOnShow, _withOnShow, add, add, add, add, apply, applyIf, applyIfPresent, component, equals, get, getComponent, getType, hashCode, peek, toString
-
Method Details
-
_state
Description copied from class:UIForAnythingReturns the state of the builder, which is a container for the wrapped component as well as it's type and currentEventProcessor.- Specified by:
_statein classUIForAnything<UIForSplitButton<B extends JSplitButton>,B extends JSplitButton, JComponent> - Returns:
- The state of the builder.
-
_newBuilderWithState
Description copied from class:UIForAnythingAn internal wither method which creates a new builder instance with the providedBuilderStatestored inside it.- Specified by:
_newBuilderWithStatein classUIForAnything<UIForSplitButton<B extends JSplitButton>,B extends JSplitButton, JComponent> - Parameters:
newState- The new state which should be stored inside the new builder instance.- Returns:
- A new builder instance with the provided state stored inside it.
-
withSelection
public <E extends Enum<E>> UIForSplitButton<B> withSelection(sprouts.Var<E> selection, sprouts.Event clickEvent) Use this to buildJSplitButtons where the selectable options are represented by anEnumtype, and the click event is handles by anEventinstance.- Type Parameters:
E- TheEnumtype defining the selectable options.- Parameters:
selection- TheVarwhich holds the currently selectedEnumvalue. This will be updated when the user selects a new value.clickEvent- TheEventwhich will be fired when the user clicks on the button.- Returns:
- A UI builder instance wrapping a
JSplitButton.
-
withSelection
public <E extends Enum<E>> UIForSplitButton<B> withSelection(sprouts.Var<E> selection, sprouts.Event clickEvent, Function<E, String> textProvider) Allows you to buildJSplitButtons where the selectable options are represented by anEnumtype, and the click event is handled by anEventinstance as well as a "text provider", which is a function that maps an enum value to a string to be used as the button text displayed to the user.- Type Parameters:
E- TheEnumtype defining the selectable options.- Parameters:
selection- TheVarwhich holds the currently selectedEnumvalue. This will be updated when the user selects a new value.clickEvent- TheEventwhich will be fired when the user clicks on the button.textProvider- A function which provides the text representation of an enum value. If this function throws an exception, the enum value'sEnum.toString()method will be used as a fallback. Exceptions are logged as errors.- Returns:
- The next declarative UI builder for the
JSplitButtontype.
-
withSelection
Use this to buildJSplitButtons where the selectable options are represented by anEnumtype. Changes to the selected value are propagated to the providedVarinstance, and the text representation of the selected value is determined using theEnum.toString()method.- Type Parameters:
E- TheEnumtype defining the selectable options.- Parameters:
selection- TheVarwhich holds the currently selectedEnumvalue. This will be updated when the user selects a new value.- Returns:
- A UI builder instance wrapping a
JSplitButton.
-
withSelection
public <E extends Enum<E>> UIForSplitButton<B> withSelection(sprouts.Var<E> selection, Function<E, String> textProvider) Use this to buildJSplitButtons where the selectable options are represented by anEnumtype. Changes to the selected value are propagated to the providedVarinstance, and the text representation of the selected value is dynamically determined through the supplied text provider function.- Type Parameters:
E- TheEnumtype defining the selectable options.- Parameters:
selection- TheVarwhich holds the currently selectedEnumvalue. This will be updated when the user selects a new value.textProvider- A function which provides the text representation of an enum value. If this function throws an exception, the enum value'sEnum.toString()method will be used as a fallback. Exceptions are logged as errors.- Returns:
- A UI builder instance wrapping a
JSplitButton.
-
onSplitClick
Actions registered here will be called when the split part of theJSplitButtonwas clicked. The provided lambda receives a delegate object with a rich API exposing a lot of context information including not only the currentJSplitButtoninstance, but also the currently selectedJMenuItemand a list of all other items.- Parameters:
action- TheActionwhich will receive anComponentDelegateexposing all essential components making up thisJSplitButton.- Returns:
- This very instance, which enables builder-style method chaining.
-
onSelection
Actions registered here will be called when the user selects aJMenuItemfrom the popup menu of thisJSplitButton. The delegate passed to the provided action lambda exposes a lot of context information including not only the currentJSplitButtoninstance, but also the currently selectedJMenuItemand a list of all other items.- Parameters:
action- TheActionwhich will receive anSplitItemDelegateexposing all essential components making up thisJSplitButton.- Returns:
- This very instance, which enables builder-style method chaining.
- Throws:
IllegalArgumentException- if the provided action is null.
-
onButtonClick
Use this as an alternative toonClick(Action)to register a button click action with an action lambda having access to a delegate with more context information including not only the currentJSplitButtoninstance, but also the currently selectedJMenuItemand a list of all other items.- Parameters:
action- TheActionwhich will receive anComponentDelegateexposing all essential components making up thisJSplitButton.- Returns:
- This very instance, which enables builder-style method chaining.
-
onClick
Use this to register a basic action for when theJSplitButtonbutton is being clicked (not the split part). If you need more context information delegated to the action then consider usingonButtonClick(Action).- Overrides:
onClickin classUIForAnyButton<UIForSplitButton<B extends JSplitButton>,B extends JSplitButton> - Parameters:
action- AnActioninstance which will be wrapped by anComponentDelegateand passed to the button component.- Returns:
- This very instance, which enables builder-style method chaining.
-
onOpen
Registers a listener to be notified when the split button is opened, meaning its popup menu is shown after the user clicks on the split button drop down button.- Parameters:
action- the action to be executed when the split button is opened.- Returns:
- this very instance, which enables builder-style method chaining.
-
onClose
Registers a listener to be notified when the split button is closed, meaning its popup menu is hidden after the user clicks on the split button drop down button.- Parameters:
action- the action to be executed when the split button is closed.- Returns:
- this very instance, which enables builder-style method chaining.
-
onCancel
Registers a listener to be notified when the split button options drop down popup is canceled, which typically happens when the user clicks outside the popup menu.- Parameters:
action- the action to be executed when the split button popup is canceled.- Returns:
- this very instance, which enables builder-style method chaining.
-
add
Use this to add aJMenuItemto theJSplitButtonpopup menu.- Type Parameters:
M- The type of theJMenuItemwrapped by the givenUIForMenuIteminstance.- Parameters:
forItem- The builder whose wrappedJMenuItemwill be added to and exposed by theJSplitButtononce the split part was pressed.- Returns:
- This very instance, which enables builder-style method chaining.
-
add
Use this to add aJMenuItemto theJSplitButtonpopup menu.- Parameters:
item- AJMenuItemwhich will be exposed by thisJSplitButtononce the split part was pressed.- Returns:
- This very instance, which enables builder-style method chaining.
-
add
Use this to add aSplitItemto theJSplitButtonpopup menu.- Type Parameters:
I- TheJMenuItemtype which should be added to thisJSplitButtonbuilder.- Parameters:
splitItem- TheSplitIteminstance wrapping aJMenuItemas well as some associatedActions.- Returns:
- This very instance, which enables builder-style method chaining.
-