Package swingtree
Class UIForTextField<F extends JTextField>
java.lang.Object
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 providedBuilderState
stored 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 numericVal
property but only for reading purposes.final <N extends Number>
UIForTextField<F> withNumber
(sprouts.Var<N> number) Effectively bind this text field to a numericVar
property 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 numericVar
property 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 numericVar
property 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 bind this text field to a numericVar
property 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 aVal
property.final UIForTextField
<F> withTextOrientation
(UI.HorizontalAlignment orientation) The providedUI.HorizontalAlignment
translates 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, onContentChange, onTextChange, onTextInsert, onTextRemove, onTextReplace, withFont, withFont, withText, withText, withText
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<UIForTextField<F extends JTextField>,
F extends JTextField, 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<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 numericVar
property which will only accept numbers as input.- Type Parameters:
N
- The numeric type of theVar
property.- Parameters:
number
- The numericVar
property 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 numericVar
property which will only accept numbers as input.- Type Parameters:
N
- The numeric type of theVar
property.- Parameters:
number
- The numericVar
property to bind to.isValid
- AVar
property which will be set totrue
if the input is valid, andfalse
otherwise.- 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 numericVar
property 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 theVar
property.- Parameters:
number
- The numericVar
property 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 bind this text field to a numericVar
property which will only accept numbers as input.- Type Parameters:
N
- The numeric type of theVar
property.- Parameters:
number
- The numericVar
property to bind to.isValid
- AVar
property which will be set totrue
if the input is valid, andfalse
otherwise.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 numericVal
property but only for reading purposes. So the text field will be updated when theVal
property changes but the user will not be able to change theVal
property since theVal
property is read-only.- Type Parameters:
N
- The numeric type of theVal
property.- Parameters:
number
- The numericVal
property to bind to.- Returns:
- This builder node.
-
withTextOrientation
The providedUI.HorizontalAlignment
translates toJTextField.setHorizontalAlignment(int)
instances which are used to align the elements or text within the wrappedJTextComponent
.LayoutManager
andComponent
subclasses 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 aVal
property, 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 aVal
property. When the item of theVal
property 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.
-