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 theJToggleButtonsubtype 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> IisSelectedIf(E state, sprouts.Var<E> selection) Use this to dynamically bind the selection flag of the button to aVarproperty 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, 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, _newBuilderWithState, _onShow, _onShow, _onShowDelegated, _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 aVarproperty 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 firststateargument is equal to the value of theselectionproperty, 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.fireChange(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 thisJToggleButtonshould represent.selection- TheVarinstance which will be used to dynamically model the selection state of the wrappedJToggleButtontype based on the equality of thestateargument and the value of the property.- Returns:
- The current builder type, to allow for further method chaining.
- Throws:
IllegalArgumentException- ifselectedisnull.
-