- Type Parameters:
R- the input result type
- All Known Implementing Classes:
ChoiceInputControl,ComboBoxEx,FileInput,OptionsPane,RadioPane,SimpleInputControl
public interface InputControl<R>
Interface for an input field.
-
Property Summary
PropertiesTypePropertyDescriptionProvides a read-only property representing the error message for this input control.Provides a read-only property representing the validity of the input.Provides the property representing the value of this input control. -
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classState class encapsulates a value, validation logic, error message, and validity state. -
Method Summary
Modifier and TypeMethodDescriptionstatic SimpleInputControl<CheckBox,Boolean> Creates aSimpleInputControlfor aCheckBoxwith a default value, text, and validation function.static InputControl<Path>chooseFile(Supplier<Path> dflt, FileDialogMode mode, boolean existingOnly, Collection<FileChooser.ExtensionFilter> filters, Function<Path, Optional<String>> validate) Provides a file chooser input control.static <T> SimpleInputControl<ComboBoxEx<T>,T> comboBoxExInput(Collection<T> choices, Supplier<T> dflt, @Nullable UnaryOperator<T> edit, @Nullable Supplier<T> add, @Nullable BiPredicate<ComboBoxEx<T>, T> remove, Function<T, String> format, Function<T, Optional<String>> validate) Creates a newSimpleInputControlfor aComboBoxExwith the specified parameters.static <T> SimpleInputControl<ComboBox<T>,T> comboBoxInput(Collection<? extends T> choices, Supplier<T> dflt, Function<T, Optional<String>> validate) static SimpleInputControl<TextField,Double> Creates aSimpleInputControlfor decimal input using aTextField.Provides a read-only property representing the error message for this input control.default Rget()Get value.default voidinit()Set/update control state.static SimpleInputControl<TextField,Integer> Creates aSimpleInputControlfor integer values.default booleanisValid()Test if content is valid.node()Get theNodefor this input element.voidreset()Reset value to defaultdefault voidSet value.static SimpleInputControl<TextField,String> Creates aSimpleInputControlfor a TextField with String input.static <T> SimpleInputControl<TextField,T> stringInput(Supplier<T> dflt, Function<T, Optional<String>> validate, StringConverter<T> converter) Creates a newSimpleInputControlfor aTextFieldwith bidirectional binding.Provides a read-only property representing the validity of the input.Provides the property representing the value of this input control.
-
Property Details
-
value
Provides the property representing the value of this input control. -
valid
ReadOnlyBooleanProperty validPropertyProvides a read-only property representing the validity of the input.- See Also:
-
error
ReadOnlyStringProperty errorPropertyProvides a read-only property representing the error message for this input control.This property contains an error message if the input is invalid, otherwise it is empty.
-
-
Method Details
-
stringInput
static SimpleInputControl<TextField,String> stringInput(Supplier<String> dflt, Function<String, Optional<String>> validate) Creates aSimpleInputControlfor a TextField with String input.- Parameters:
dflt- aSupplierproviding the default value for the TextFieldvalidate- aFunctionthat takes a String and returns an Optional containing a validation error message, if any- Returns:
- a
SimpleInputControlcontaining the TextField and associated properties
-
stringInput
static <T> SimpleInputControl<TextField,T> stringInput(Supplier<T> dflt, Function<T, Optional<String>> validate, StringConverter<T> converter) Creates a newSimpleInputControlfor aTextFieldwith bidirectional binding.- Type Parameters:
T- The type of the value.- Parameters:
dflt- The supplier providing the default value.validate- A function to validate the value, returning an optional error message.converter- The StringConverter to convert between the value and its string representation.- Returns:
- A
SimpleInputControlcontaining theTextFieldand associated properties.
-
integerInput
static SimpleInputControl<TextField,Integer> integerInput(Supplier<Integer> dflt, Function<Integer, Optional<String>> validate) Creates aSimpleInputControlfor integer values.- Parameters:
dflt- the default valueSuppliervalidate- theFunctionto validate the integer input- Returns:
- a
SimpleInputControlfor integer input
-
decimalInput
static SimpleInputControl<TextField,Double> decimalInput(Supplier<Double> dflt, Function<Double, Optional<String>> validate) Creates aSimpleInputControlfor decimal input using aTextField.- Parameters:
dflt- theSupplierproviding the default value for the inputvalidate- theFunctionto validate the input value- Returns:
- a
SimpleInputControlthat manages a TextField for Decimal input
-
checkBoxInput
static SimpleInputControl<CheckBox,Boolean> checkBoxInput(Supplier<Boolean> dflt, String text, Function<Boolean, Optional<String>> validate) Creates aSimpleInputControlfor aCheckBoxwith a default value, text, and validation function.- Parameters:
dflt- aSupplierproviding the default Boolean valuetext- the text to be displayed with theCheckBoxvalidate- aFunctionthat takes a Boolean value and returns anOptionalcontaining an error message if validation fails- Returns:
- a new instance of
SimpleInputControlconfigured with aCheckBoxand the provided parameters
-
comboBoxInput
static <T> SimpleInputControl<ComboBox<T>,T> comboBoxInput(Collection<? extends T> choices, Supplier<T> dflt, Function<T, Optional<String>> validate) Creates aComboBoxinput control with specified choices, default valueSupplier, and validationFunction.- Type Parameters:
T- the type of the items in theComboBox- Parameters:
choices- the collection of available choices for theComboBoxdflt- aSupplierproviding the default valuevalidate- aFunctionto validate the selected item which returns an optional error message- Returns:
- a
SimpleInputControlcontaining the ComboBox and its value property
-
comboBoxExInput
static <T> SimpleInputControl<ComboBoxEx<T>,T> comboBoxExInput(Collection<T> choices, Supplier<T> dflt, @Nullable UnaryOperator<T> edit, @Nullable Supplier<T> add, @Nullable BiPredicate<ComboBoxEx<T>, T> remove, Function<T, String> format, Function<T, Optional<String>> validate) Creates a newSimpleInputControlfor aComboBoxExwith the specified parameters.- Type Parameters:
T- the type of items contained in theComboBoxEx- Parameters:
choices- the collection of choices to populate theComboBoxExdflt- aSupplierfor the default valueedit- aUnaryOperatorto perform editing on the selected item (nullable)add- aSupplierto provide a new item to add (nullable)remove- aBiPredicateto determine if an item should be removed (nullable)format- aFunctionto format the items as stringsvalidate- aFunctionto validate the current value- Returns:
- a new instance of
SimpleInputControlconfigured with aComboBoxExand its value property
-
chooseFile
static InputControl<Path> chooseFile(Supplier<Path> dflt, FileDialogMode mode, boolean existingOnly, Collection<FileChooser.ExtensionFilter> filters, Function<Path, Optional<String>> validate) Provides a file chooser input control.- Parameters:
dflt- aSupplierproviding the default file path.mode- theFileDialogModeof the dialog (e.g., OPEN, SAVE, DIRECTORY).existingOnly- specifies if only existing files can be chosen.filters- aCollectionofFileChooser.ExtensionFilterto apply.validate- aFunctionthat validates the selected file path.- Returns:
- An
InputControlinstance for file selection.
-
node
Node node()Get theNodefor this input element.- Returns:
- the node
-
get
Get value.- Returns:
- the current value
-
valueProperty
Provides the property representing the value of this input control. -
set
Set value.- Parameters:
arg- the value to set
-
isValid
default boolean isValid()Test if content is valid.- Returns:
- true, if content is valid
-
init
default void init()Set/update control state. -
reset
void reset()Reset value to default -
validProperty
ReadOnlyBooleanProperty validProperty()Provides a read-only property representing the validity of the input.- See Also:
-
errorProperty
ReadOnlyStringProperty errorProperty()Provides a read-only property representing the error message for this input control.This property contains an error message if the input is invalid, otherwise it is empty.
-