Package swingtree
Class UIForAnyToggleButton<I,B extends JToggleButton>
java.lang.Object
swingtree.UIForAnything<I,B,JComponent>
swingtree.UIForAnySwing<I,B>
swingtree.UIForAnyButton<I,B>
swingtree.UIForAnyToggleButton<I,B>
- Type Parameters:
I
- The type of this builder node.B
- The type of theJToggleButton
subtype which will be managed by this builder.
- Direct Known Subclasses:
UIForRadioButton
,UIForToggleButton
An abstract precursor for swing tree builder nodes for
JToggleButton
instances.
Extend this class to create a builder node for a custom JToggleButton
subtype.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal <E> I
isSelectedIf
(E state, sprouts.Var<E> selection) Use this to dynamically bind the selection flag of the button to aVar
property which will determine the selection state of the button based on the equality of the property value and the provided reference value.Methods inherited from class swingtree.UIForAnyButton
_onChange, _onClick, _onModelChange, isBorderPaintedIf, isBorderPaintedIf, isPressedIf, isSelectedIf, isSelectedIf, isSelectedIf, isSelectedIf, isSelectedIfNot, isSelectedIfNot, isSelectedIfNot, makePlain, onChange, onClick, 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, _newBuilderWithState, _onShow, _onShow, _runInApp, _runInApp, _runInUI, _state, _this, _with, _withOnShow, _withOnShow, add, add, add, add, apply, applyIf, applyIfPresent, component, equals, get, getComponent, getType, hashCode, peek, toString
-
Constructor Details
-
UIForAnyToggleButton
public UIForAnyToggleButton()
-
-
Method Details
-
isSelectedIf
Use this to dynamically bind the selection flag of the button to aVar
property which will determine the selection state of the button based on the equality of the property value and the provided reference value. So if the firststate
argument is equal to the value of theselection
property, the button will be selected, otherwise it will be deselected.
A typical use case is to bind a button to an enum property, like so:
As you can see, the radio button will be selected if the enum property is equal to the supplied enum value and deselected otherwise.// In your view model: enum Step { ONE, TWO, THREE } Var<Step> step = Var.of(Step.ONE); // In your view: UI.radioButton("Two").isSelectedIf(Step.TWO, vm.getStep());
Hint: UsemyProperty.fire(From.VIEW_MODEL)
in your view model to send the property value to this view component.- Type Parameters:
E
- The type of the property value.- Parameters:
state
- The reference value which thisJToggleButton
should represent.selection
- TheVar
instance which will be used to dynamically model the selection state of the wrappedJToggleButton
type based on the equality of thestate
argument and the value of the property.- Returns:
- The current builder type, to allow for further method chaining.
- Throws:
IllegalArgumentException
- ifselected
isnull
.
-