Package swingtree
Class UIForSplitButton<B extends JSplitButton>
java.lang.Object
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 providedBuilderState
stored 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 aJMenuItem
to theJSplitButton
popup menu.<I extends JMenuItem>
UIForSplitButton<B> Use this to add aSplitItem
to theJSplitButton
popup menu.<M extends JMenuItem>
UIForSplitButton<B> add
(UIForMenuItem<M> forItem) Use this to add aJMenuItem
to theJSplitButton
popup 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 currentJSplitButton
instance, but also the currently selectedJMenuItem
and 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 theJSplitButton
button 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) Action
s registered here will be called when the user selects aJMenuItem
from the popup menu of thisJSplitButton
.onSplitClick
(sprouts.Action<SplitButtonDelegate<JMenuItem>> action) Action
s registered here will be called when the split part of theJSplitButton
was clicked.<E extends Enum<E>>
UIForSplitButton<B> withSelection
(sprouts.Var<E> selection) Use this to buildJSplitButton
s where the selectable options are represented by anEnum
type.<E extends Enum<E>>
UIForSplitButton<B> withSelection
(sprouts.Var<E> selection, Function<E, String> textProvider) Use this to buildJSplitButton
s where the selectable options are represented by anEnum
type.<E extends Enum<E>>
UIForSplitButton<B> withSelection
(sprouts.Var<E> selection, sprouts.Event clickEvent) Use this to buildJSplitButton
s where the selectable options are represented by anEnum
type, and the click event is handles by anEvent
instance.<E extends Enum<E>>
UIForSplitButton<B> withSelection
(sprouts.Var<E> selection, sprouts.Event clickEvent, Function<E, String> textProvider) Allows you to buildJSplitButton
s where the selectable options are represented by anEnum
type, and the click event is handled by anEvent
instance 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, withFontSize, withFontSize, withHorizontalAlignment, withHorizontalAlignment, withHorizontalTextAlignment, withHorizontalTextAlignment, withIcon, withIcon, withIcon, withIcon, withIcon, withIcon, withIcon, withIcon, withMargin, withMargin, withText, withText, withVerticalAlignment, withVerticalAlignment, withVerticalTextAlignment, withVerticalTextAlignment
Methods inherited from class swingtree.UIForAnySwing
_addComponentTo, _addViewableProps, _addViewableProps, _isUndefinedColor, _isUndefinedFont, _setBackground, _setEnabled, _setMinHeight, _setMinWidth, _setPrefWidth, add, add, add, add, add, add, add, add, add, add, 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, 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, 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, withWidthExactly
Methods inherited from class swingtree.UIForAnything
_addBuildersTo, _addBuilderTo, _addComponentsTo, _disposeState, _onShow, _onShow, _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:UIForAnything
Returns the state of the builder, which is a container for the wrapped component as well as it's type and currentEventProcessor
.- Specified by:
_state
in classUIForAnything<UIForSplitButton<B extends JSplitButton>,
B extends JSplitButton, JComponent> - Returns:
- The state of the builder.
-
_newBuilderWithState
Description copied from class:UIForAnything
An internal wither method which creates a new builder instance with the providedBuilderState
stored inside it.- Specified by:
_newBuilderWithState
in 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 buildJSplitButton
s where the selectable options are represented by anEnum
type, and the click event is handles by anEvent
instance.- Type Parameters:
E
- TheEnum
type defining the selectable options.- Parameters:
selection
- TheVar
which holds the currently selectedEnum
value. This will be updated when the user selects a new value.clickEvent
- TheEvent
which 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 buildJSplitButton
s where the selectable options are represented by anEnum
type, and the click event is handled by anEvent
instance 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
- TheEnum
type defining the selectable options.- Parameters:
selection
- TheVar
which holds the currently selectedEnum
value. This will be updated when the user selects a new value.clickEvent
- TheEvent
which 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
JSplitButton
type.
-
withSelection
Use this to buildJSplitButton
s where the selectable options are represented by anEnum
type. Changes to the selected value are propagated to the providedVar
instance, and the text representation of the selected value is determined using theEnum.toString()
method.- Type Parameters:
E
- TheEnum
type defining the selectable options.- Parameters:
selection
- TheVar
which holds the currently selectedEnum
value. 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 buildJSplitButton
s where the selectable options are represented by anEnum
type. Changes to the selected value are propagated to the providedVar
instance, and the text representation of the selected value is dynamically determined through the supplied text provider function.- Type Parameters:
E
- TheEnum
type defining the selectable options.- Parameters:
selection
- TheVar
which holds the currently selectedEnum
value. 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
Action
s registered here will be called when the split part of theJSplitButton
was clicked. The provided lambda receives a delegate object with a rich API exposing a lot of context information including not only the currentJSplitButton
instance, but also the currently selectedJMenuItem
and a list of all other items.- Parameters:
action
- TheAction
which will receive anComponentDelegate
exposing all essential components making up thisJSplitButton
.- Returns:
- This very instance, which enables builder-style method chaining.
-
onSelection
Action
s registered here will be called when the user selects aJMenuItem
from the popup menu of thisJSplitButton
. The delegate passed to the provided action lambda exposes a lot of context information including not only the currentJSplitButton
instance, but also the currently selectedJMenuItem
and a list of all other items.- Parameters:
action
- TheAction
which will receive anSplitItemDelegate
exposing 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 currentJSplitButton
instance, but also the currently selectedJMenuItem
and a list of all other items.- Parameters:
action
- TheAction
which will receive anComponentDelegate
exposing 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 theJSplitButton
button is being clicked (not the split part). If you need more context information delegated to the action then consider usingonButtonClick(Action)
.- Overrides:
onClick
in classUIForAnyButton<UIForSplitButton<B extends JSplitButton>,
B extends JSplitButton> - Parameters:
action
- AnAction
instance which will be wrapped by anComponentDelegate
and 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 aJMenuItem
to theJSplitButton
popup menu.- Type Parameters:
M
- The type of theJMenuItem
wrapped by the givenUIForMenuItem
instance.- Parameters:
forItem
- The builder whose wrappedJMenuItem
will be added to and exposed by theJSplitButton
once the split part was pressed.- Returns:
- This very instance, which enables builder-style method chaining.
-
add
Use this to add aJMenuItem
to theJSplitButton
popup menu.- Parameters:
item
- AJMenuItem
which will be exposed by thisJSplitButton
once the split part was pressed.- Returns:
- This very instance, which enables builder-style method chaining.
-
add
Use this to add aSplitItem
to theJSplitButton
popup menu.- Type Parameters:
I
- TheJMenuItem
type which should be added to thisJSplitButton
builder.- Parameters:
splitItem
- TheSplitItem
instance wrapping aJMenuItem
as well as some associatedAction
s.- Returns:
- This very instance, which enables builder-style method chaining.
-