Module is.codion.swing.common.ui
Interface ComponentValueBuilder<T,C extends JComponent,B extends ComponentValueBuilder<T,C,B>>
- Type Parameters:
T
- the type of the value the component representsC
- the component typeB
- the builder type
- All Superinterfaces:
ComponentBuilder<C,
,B> Supplier<C>
- All Known Subinterfaces:
ButtonBuilder<T,
,C, B> CheckBoxBuilder
,CheckBoxMenuItemBuilder<B>
,ComboBoxBuilder<T,
,C, B> EntityComboBox.Builder
,EntityComboBoxPanel.Builder
,EntitySearchField.Builder<T,
,B> EntitySearchField.MultiSelectionBuilder
,EntitySearchField.SingleSelectionBuilder
,EntitySearchFieldPanel.Builder<T,
,B> EntitySearchFieldPanel.MultiSelectionBuilder
,EntitySearchFieldPanel.SingleSelectionBuilder
,FileInputPanel.Builder<T>
,ItemComboBoxBuilder<T>
,ItemSpinnerBuilder<T>
,LabelBuilder<T>
,ListBoxBuilder<T>
,ListBuilder<T,
,V, B> ListBuilder.Items<T>
,ListBuilder.SelectedItem<T>
,ListBuilder.SelectedItems<T>
,ListSpinnerBuilder<T>
,MaskedTextFieldBuilder
,MenuItemBuilder<C,
,B> NumberField.Builder<T>
,NumberSpinnerBuilder<T>
,PasswordFieldBuilder
,ProgressBarBuilder
,RadioButtonBuilder
,RadioButtonMenuItemBuilder<B>
,SliderBuilder
,SpinnerBuilder<T,
,B> TemporalField.Builder<T>
,TemporalFieldPanel.Builder<T>
,TextAreaBuilder
,TextComponentBuilder<T,
,C, B> TextFieldBuilder<T,
,C, B> TextFieldPanel.Builder
,TextPaneBuilder
,ToggleButtonBuilder<C,
,B> ToggleMenuItemBuilder<C,
B>
- All Known Implementing Classes:
AbstractComponentValueBuilder
,DefaultComboBoxBuilder
public interface ComponentValueBuilder<T,C extends JComponent,B extends ComponentValueBuilder<T,C,B>>
extends ComponentBuilder<C,B>, Supplier<C>
Use
The component is available via
ComponentBuilder.build()
to build a JComponent instance or buildValue()
to build a ComponentValue
instance.The component is available via
ComponentValue.component()
and the associated ComponentValue
instance
is available via the COMPONENT_VALUE
client property.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
The client property key for the associatedComponentValue
JTextField textField = Components.stringField() .build(); ComponentValue<String, JTextField> componentValue = (ComponentValue<String, JTextField>) textField.getClientProperty(COMPONENT_VALUE);
-
Method Summary
Modifier and TypeMethodDescriptionBuilds and returns the component value.buildValue
(@Nullable Consumer<ComponentValue<T, C>> onBuild) Builds and returns the component value.link
(Observable<T> linkedValue) Creates a read-only link to the givenObservable
.Creates a bidirectional link to the given value.modifiedIndicator
(@Nullable ObservableState modified) Enables a modified indicator based on the given modified state.modifiedIndicatorFactory
(@Nullable ModifiedIndicatorFactory modifiedIndicatorFactory) By defaultUnderlineModifiedIndicatorFactory
.onBuildValue
(Consumer<ComponentValue<T, C>> onBuildValue) validator
(Value.Validator<T> validator) Enables a valid indicator based on the given valid state.validIndicator
(@Nullable Predicate<T> validator) Enables a valid indicator based on the given validator.validIndicatorFactory
(@Nullable ValidIndicatorFactory validIndicatorFactory) Sets the initial value for the component, unless value(s) have been linked vialink(Value)
orlink(Observable)
, which then control the inital value.Methods inherited from interface is.codion.swing.common.ui.component.builder.ComponentBuilder
background, border, build, build, clientProperty, componentListener, componentOrientation, enabled, enabled, focusable, focusable, focusCycleRoot, focusListener, font, foreground, get, keyEvent, keyListener, label, label, maximumHeight, maximumSize, maximumWidth, minimumHeight, minimumSize, minimumWidth, mouseListener, mouseMotionListener, mouseWheelListener, name, onBuild, onSetVisible, opaque, popupMenu, popupMenuControl, popupMenuControls, preferredHeight, preferredSize, preferredWidth, propertyChangeListener, propertyChangeListener, scrollPane, toolTipText, toolTipText, transferFocusOnEnter, transferFocusOnEnter, transferHandler, visible, visible
-
Field Details
-
COMPONENT_VALUE
The client property key for the associatedComponentValue
JTextField textField = Components.stringField() .build(); ComponentValue<String, JTextField> componentValue = (ComponentValue<String, JTextField>) textField.getClientProperty(COMPONENT_VALUE);
- See Also:
-
-
Method Details
-
value
Sets the initial value for the component, unless value(s) have been linked vialink(Value)
orlink(Observable)
, which then control the inital value. The initial value is set before any listeners are added, so no events are triggered.- Parameters:
value
- the initial value- Returns:
- this builder instance
-
modifiedIndicator
Enables a modified indicator based on the given modified state.- Parameters:
modified
- the modified state- Returns:
- this builder instance
- See Also:
-
validIndicatorFactory
- Parameters:
validIndicatorFactory
- theValidIndicatorFactory
to use, null for none- Returns:
- this builder instance
- See Also:
-
validIndicator
Enables a valid indicator based on the given valid state.- Parameters:
valid
- the valid state- Returns:
- this builder instance
- See Also:
-
validIndicator
Enables a valid indicator based on the given validator. Note that this is overridden by
validIndicator(ObservableState)
.The validator gets called each time the value changes and should return true as long as the value is valid.
- Parameters:
validator
- called each time the component value changes- Returns:
- this builder instance
- See Also:
-
modifiedIndicatorFactory
By defaultUnderlineModifiedIndicatorFactory
.- Parameters:
modifiedIndicatorFactory
- theModifiedIndicatorFactory
to use, null for none- Returns:
- this builder instance
-
validator
- Parameters:
validator
- the validator to use- Returns:
- this builder instance
-
link
Creates a bidirectional link to the given value. Overrides any initial value set.- Parameters:
linkedValue
- a value to link to the component value- Returns:
- this builder instance
-
link
Creates a read-only link to the givenObservable
.- Parameters:
linkedValue
- a value to link to the component value- Returns:
- this builder instance
-
listener
- Parameters:
listener
- a listener to add to the resulting component value- Returns:
- this builder instance
-
consumer
- Parameters:
consumer
- a consumer to add to the resulting component value- Returns:
- this builder instance
-
onBuildValue
- Parameters:
onBuildValue
- called when the component value has been built.- Returns:
- this builder instance
-
buildValue
ComponentValue<T,C> buildValue()Builds and returns the component value.- Returns:
- the component value
-
buildValue
Builds and returns the component value.- Parameters:
onBuild
- called after the component value is built.- Returns:
- the component value
-