Package swingtree
Class UIForTextField<F extends JTextField>
java.lang.Object
- Type Parameters:
F- The type of text field that is being assembled by this declarative builder/
public final class UIForTextField<F extends JTextField>
extends UIForAnyTextComponent<UIForTextField<F>,F>
A SwingTree builder node designed for configuring
JTextField instances.
Take a look at the living swing-tree documentation where you can browse a large collection of examples demonstrating how to use the API of this class or other classes.
-
Method Summary
Modifier and TypeMethodDescriptionprotected UIForTextField<F> _newBuilderWithState(swingtree.BuilderState<F> newState) An internal wither method which creates a new builder instance with the providedBuilderStatestored inside it.protected swingtree.BuilderState<F> _state()Returns the state of the builder, which is a container for the wrapped component as well as it's type and currentEventProcessor.onEnter(sprouts.Action<ComponentDelegate<F, ActionEvent>> action) Allows you to register an action to be performed when the user presses the enter key.final <N extends Number>
UIForTextField<F> withNumber(sprouts.Val<N> number) Effectively bind this text field to a numericValproperty but only for reading purposes.final <N extends Number>
UIForTextField<F> withNumber(sprouts.Var<N> number) Effectively bind this text field to a numericVarproperty which will only accept numbers as input.final <N extends Number>
UIForTextField<F> withNumber(sprouts.Var<N> number, Function<N, String> formatter) Binds this text field to a numericVarproperty which will only accept numbers as input and a custom formatter which turns the number into a string.final <N extends Number>
UIForTextField<F> withNumber(sprouts.Var<N> number, sprouts.Var<Boolean> isValid) Effectively bind this text field to a numericVarproperty which will only accept numbers as input.final <N extends Number>
UIForTextField<F> withNumber(sprouts.Var<N> number, sprouts.Var<Boolean> isValid, Function<N, String> formatter) Effectively binds this text field to a numericVarproperty which will only accept numbers as input.final UIForTextField<F> withPlaceholder(String placeholder) Sets the placeholder text of this text field to a static string.final UIForTextField<F> withPlaceholder(sprouts.Val<String> placeholder) Binds the placeholder text of this text field to aValproperty.final UIForTextField<F> withTextOrientation(UI.HorizontalAlignment orientation) The providedUI.HorizontalAlignmenttranslates toJTextField.setHorizontalAlignment(int)instances which are used to align the elements or text within the wrappedJTextComponent.Methods inherited from class swingtree.UIForAnyTextComponent
_onTextChange, _setTextSilently, isEditableIf, isEditableIf, isEditableIfNot, onContentChange, onTextChange, onTextInsert, onTextRemove, onTextReplace, withFont, withFont, withText, withText, withTextMethods 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, 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, 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<UIForTextField<F extends JTextField>,F extends JTextField, 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<UIForTextField<F extends JTextField>,F extends JTextField, 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.
-
onEnter
Allows you to register an action to be performed when the user presses the enter key.- Parameters:
action- The action to be performed.- Returns:
- This very instance, which enables builder-style method chaining.
-
withNumber
Effectively bind this text field to a numericVarproperty which will only accept numbers as input.- Type Parameters:
N- The numeric type of theVarproperty.- Parameters:
number- The numericVarproperty to bind to.- Returns:
- This builder node.
-
withNumber
public final <N extends Number> UIForTextField<F> withNumber(sprouts.Var<N> number, sprouts.Var<Boolean> isValid) Effectively bind this text field to a numericVarproperty which will only accept numbers as input.- Type Parameters:
N- The numeric type of theVarproperty.- Parameters:
number- The numericVarproperty to bind to.isValid- AVarproperty which will be set totrueif the input is valid, andfalseotherwise.- Returns:
- This builder node.
-
withNumber
public final <N extends Number> UIForTextField<F> withNumber(sprouts.Var<N> number, Function<N, String> formatter) Binds this text field to a numericVarproperty which will only accept numbers as input and a custom formatter which turns the number into a string.- Type Parameters:
N- The numeric type of theVarproperty.- Parameters:
number- The numericVarproperty to bind to.formatter- A function which will be used to format the number as a string.- Returns:
- This builder node.
-
withNumber
public final <N extends Number> UIForTextField<F> withNumber(sprouts.Var<N> number, sprouts.Var<Boolean> isValid, Function<N, String> formatter) Effectively binds this text field to a numericVarproperty which will only accept numbers as input. When the user types in a number, theVarproperty will be updated accordingly. Conversely, when theVarproperty changes, the text of the text field will display the new value.- Type Parameters:
N- The numeric type of theVarproperty.- Parameters:
number- The numericVarproperty to bind to.isValid- AVarproperty which will be set totrueif the input is valid, andfalseotherwise.formatter- A function which will be used to format the number as a string.- Returns:
- This builder node.
-
withNumber
Effectively bind this text field to a numericValproperty but only for reading purposes. So the text field will be updated when theValproperty changes but the user will not be able to change theValproperty since theValproperty is read-only.- Type Parameters:
N- The numeric type of theValproperty.- Parameters:
number- The numericValproperty to bind to.- Returns:
- This builder node.
-
withTextOrientation
The providedUI.HorizontalAlignmenttranslates toJTextField.setHorizontalAlignment(int)instances which are used to align the elements or text within the wrappedJTextComponent.LayoutManagerandComponentsubclasses will use this property to determine how to lay out and draw components.Note: This method indirectly changes layout-related information, and therefore, invalidates the component hierarchy.
- Parameters:
orientation- The text orientation type which should be used.- Returns:
- This very builder to allow for method chaining.
-
withPlaceholder
Sets the placeholder text of this text field to a static string. The placeholder text will not change.
UsewithPlaceholder(Val)to bind the placeholder text to aValproperty, so that the placeholder text can change dynamically when the property state changes.- Parameters:
placeholder- The placeholder text to set.- Returns:
- This UI builder node, to allow for method chaining.
-
withPlaceholder
Binds the placeholder text of this text field to aValproperty. When the item of theValproperty changes, the placeholder text will be updated accordingly.- Parameters:
placeholder- The placeholder property which will be listened to for changes.- Returns:
- This UI builder node, to allow for method chaining.
-