Module is.codion.swing.common.ui
Interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
- Type Parameters:
T
- the type of the value the component representsC
- the component typeB
- the builder type
- All Known Subinterfaces:
BorderLayoutPanelBuilder
,ButtonBuilder<T,
,C, B> ButtonPanelBuilder
,CheckBoxBuilder
,CheckBoxMenuItemBuilder<B>
,ComboBoxBuilder<T,
,C, B> ControlPanelBuilder<C,
,B> EntityComboBoxPanel.Builder
,EntitySearchField.Builder
,EntitySearchFieldPanel.Builder
,FileInputPanel.Builder
,FilteredTable.Builder<R,
,C> ItemComboBoxBuilder<T>
,ItemSpinnerBuilder<T>
,LabelBuilder<T>
,ListBuilder<T>
,ListSpinnerBuilder<T>
,MaskedTextFieldBuilder
,MenuBuilder
,MenuItemBuilder<C,
,B> NumberField.Builder<T>
,NumberSpinnerBuilder<T>
,PanelBuilder
,PasswordFieldBuilder
,ProgressBarBuilder
,RadioButtonBuilder
,RadioButtonMenuItemBuilder<B>
,ScrollPaneBuilder
,SliderBuilder
,SpinnerBuilder<T,
,B> SplitPaneBuilder
,TabbedPaneBuilder
,TemporalField.Builder<T>
,TemporalFieldPanel.Builder<T>
,TextAreaBuilder
,TextComponentBuilder<T,
,C, B> TextFieldBuilder<T,
,C, B> TextFieldPanel.Builder
,ToggleButtonBuilder<C,
,B> ToggleMenuItemBuilder<C,
,B> ToolBarBuilder
- All Known Implementing Classes:
AbstractComponentBuilder
,DefaultComboBoxBuilder
public interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
Builds a JComponent.
Note that once
Note that once
build()
or buildValue()
have been called they will return the same instance
on subsequent calls until the builder has been cleared by calling clear()
.-
Field Summary
Modifier and TypeFieldDescriptionstatic final PropertyValue<Boolean>
Specifies whether focus should be transferred from components on enter.
Note that for JTextArea CTRL is added to move focus forward
Value type: Boolean
Default value: false -
Method Summary
Modifier and TypeMethodDescriptionbackground
(Color background) build()
Builds and returns the component, note that subsequent calls return the same component untilclear()
has been called.Builds and returns the component, note that subsequent calls return the same component untilclear()
has been called.Builds and returns the component value, note that subsequent calls return the same component value untilclear()
has been called.clear()
Clears this builder so that it builds a new instance on next call tobuild()
orbuildValue()
.clientProperty
(Object key, Object value) Adds an arbitrary key/value "client property" to the componentcomponentListener
(ComponentListener componentListener) componentOrientation
(ComponentOrientation orientation) enabled
(boolean enabled) Sets the enabled state of the component, for a dynamic enabled state useenabled(StateObserver)
.enabled
(StateObserver enabled) focusable
(boolean focusable) focusCycleRoot
(boolean focusCycleRoot) focusListener
(FocusListener focusListener) foreground
(Color foreground) initialValue
(T initialValue) Sets the initial value for the component, overridden bylinkedValue(Value)
.keyEvent
(KeyEvents.Builder keyEventBuilder) Enables the key event defined by the givenKeyEvents.Builder
on the component.keyListener
(KeyListener keyListener) linkedValue
(Value<T> linkedValue) Creates a bidirectional link to the given value.linkedValue
(ValueObserver<T> linkedValue) Creates a read-only link to the givenValueObserver
.maximumHeight
(int maximumHeight) maximumSize
(Dimension maximumSize) maximumWidth
(int maximumWidth) minimumHeight
(int minimumHeight) minimumSize
(Dimension minimumSize) minimumWidth
(int minimumWidth) mouseListener
(MouseListener mouseListener) mouseMotionListener
(MouseMotionListener mouseMotionListener) mouseWheelListener
(MouseWheelListener mouseWheelListener) onSetVisible
(Consumer<C> onSetVisible) opaque
(boolean opaque) popupMenu
(Function<C, JPopupMenu> popupMenu) popupMenuControl
(Function<C, Control> popupMenuControl) popupMenuControls
(Function<C, Controls> popupMenuControls) preferredHeight
(int preferredHeight) preferredSize
(Dimension preferredSize) preferredWidth
(int preferredWidth) propertyChangeListener
(PropertyChangeListener propertyChangeListener) propertyChangeListener
(String propertyName, PropertyChangeListener propertyChangeListener) toolTipText
(String toolTipText) transferFocusOnEnter
(boolean transferFocusOnEnter) Note that for JTextArea CTRL is added to move focus forward and CTRL + SHIFT to move it backwardstransferHandler
(TransferHandler transferHandler) validator
(Value.Validator<T> validator) visible
(boolean visible)
-
Field Details
-
TRANSFER_FOCUS_ON_ENTER
Specifies whether focus should be transferred from components on enter.
Note that for JTextArea CTRL is added to move focus forward
Value type: Boolean
Default value: false
-
-
Method Details
-
label
- Parameters:
label
- the label for the component- Returns:
- this builder instance
- See Also:
-
focusable
- Parameters:
focusable
- false if the component should not be focusable- Returns:
- this builder instance
- See Also:
-
preferredHeight
- Parameters:
preferredHeight
- the preferred component height- Returns:
- this builder instance
-
preferredWidth
- Parameters:
preferredWidth
- the preferred component width- Returns:
- this builder instance
-
preferredSize
- Parameters:
preferredSize
- the preferred component size- Returns:
- this builder instance
- See Also:
-
maximumHeight
- Parameters:
maximumHeight
- the maximum component height- Returns:
- this builder instance
-
maximumWidth
- Parameters:
maximumWidth
- the maximum component width- Returns:
- this builder instance
-
maximumSize
- Parameters:
maximumSize
- the maximum component size- Returns:
- this builder instance
- See Also:
-
minimumHeight
- Parameters:
minimumHeight
- the minimum component height- Returns:
- this builder instance
-
minimumWidth
- Parameters:
minimumWidth
- the minimum component width- Returns:
- this builder instance
-
minimumSize
- Parameters:
minimumSize
- the minimum component size- Returns:
- this builder instance
- See Also:
-
border
- Parameters:
border
- the component border- Returns:
- this builder instance
- See Also:
-
transferFocusOnEnter
Note that for JTextArea CTRL is added to move focus forward and CTRL + SHIFT to move it backwards- Parameters:
transferFocusOnEnter
- if true then the text field transfer focus on enter (shift-enter for backwards)- Returns:
- this builder instance
- See Also:
-
toolTipText
- Parameters:
toolTipText
- the tool tip text- Returns:
- this builder instance
- See Also:
-
enabled
Sets the enabled state of the component, for a dynamic enabled state useenabled(StateObserver)
. Overridden byenabled(StateObserver)
.- Parameters:
enabled
- the enabled state- Returns:
- this builder instance
- See Also:
-
enabled
- Parameters:
enabled
- the state observer controlling the component enabled status- Returns:
- this builder instance
-
popupMenuControl
- Parameters:
popupMenuControl
- a function, receiving the component being built, providing the control to base a popup menu on- Returns:
- this builder instance
-
popupMenuControls
- Parameters:
popupMenuControls
- a function, receiving the component being built, providing the controls to base a popup menu on- Returns:
- this builder instance
-
popupMenu
- Parameters:
popupMenu
- a function, receiving the component being built, providing the popup menu- Returns:
- this builder instance
- See Also:
-
font
- Parameters:
font
- the component font- Returns:
- this builder instance
- See Also:
-
foreground
- Parameters:
foreground
- the foreground color- Returns:
- this builder instance
- See Also:
-
background
- Parameters:
background
- the background color- Returns:
- this builder instance
- See Also:
-
opaque
- Parameters:
opaque
- true if the component should be opaque- Returns:
- this builder instance
- See Also:
-
visible
- Parameters:
visible
- the initial component visibility, default true- Returns:
- this builder instance
- See Also:
-
componentOrientation
- Parameters:
orientation
- the component orientation- Returns:
- this builder instance
- See Also:
-
validator
- Parameters:
validator
- the validator to use- Returns:
- this builder instance
-
keyEvent
Enables the key event defined by the givenKeyEvents.Builder
on the component. Note that settingtransferFocusOnEnter(boolean)
to true overrides any conflicting key event based onKeyEvent.VK_ENTER
added via this method.- Parameters:
keyEventBuilder
- a key event builder to enable on the component- Returns:
- this builder instance
-
clientProperty
Adds an arbitrary key/value "client property" to the component- Parameters:
key
- the keyvalue
- the value- Returns:
- this builder instance
- See Also:
-
focusListener
- Parameters:
focusListener
- the focus listener- Returns:
- this builder instance
- See Also:
-
mouseListener
- Parameters:
mouseListener
- the mouse listener- Returns:
- this builder instance
- See Also:
-
mouseMotionListener
- Parameters:
mouseMotionListener
- the mouse motion listener- Returns:
- this builder instance
- See Also:
-
mouseWheelListener
- Parameters:
mouseWheelListener
- the mouse wheel listener- Returns:
- this builder instance
- See Also:
-
keyListener
- Parameters:
keyListener
- the key listener- Returns:
- this builder instance
- See Also:
-
componentListener
- Parameters:
componentListener
- the component listener- Returns:
- this builder instance
- See Also:
-
propertyChangeListener
- Parameters:
propertyChangeListener
- the property change listener- Returns:
- this builder instance
- See Also:
-
propertyChangeListener
- Parameters:
propertyName
- the name of the property to listen forpropertyChangeListener
- the property change listener- Returns:
- this builder instance
- See Also:
-
transferHandler
- Parameters:
transferHandler
- the transfer handler- Returns:
- this builder instance
- See Also:
-
focusCycleRoot
- Parameters:
focusCycleRoot
- true if the component should be the root of a focus traversal cycle- Returns:
- this builder instance
- See Also:
-
onSetVisible
- Parameters:
onSetVisible
- called when the component is made visible for the first time- Returns:
- this builder instance
-
linkedValue
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
-
linkedValue
Creates a read-only link to the givenValueObserver
.- Parameters:
linkedValue
- a value to link to the component value- Returns:
- this builder instance
-
initialValue
Sets the initial value for the component, overridden bylinkedValue(Value)
. Note that null is not explicitely set, the component is assumed to represent the null value right after it's been created.- Parameters:
initialValue
- the initial value- Returns:
- this builder instance
-
scrollPane
ScrollPaneBuilder scrollPane()- Returns:
- a
ScrollPaneBuilder
using this component as the view
-
onBuild
- Parameters:
onBuild
- called when the component has been built, not called on subsequent calls untilclear()
has been called.- Returns:
- this builder instance
-
build
C build()Builds and returns the component, note that subsequent calls return the same component untilclear()
has been called.- Returns:
- the component
-
build
Builds and returns the component, note that subsequent calls return the same component untilclear()
has been called.- Parameters:
onBuild
- called after the first call when the component is built, not called on subsequent calls.- Returns:
- the component
-
clear
B clear()Clears this builder so that it builds a new instance on next call tobuild()
orbuildValue()
.- Returns:
- this builder instance
-
buildValue
ComponentValue<T,C> buildValue()Builds and returns the component value, note that subsequent calls return the same component value untilclear()
has been called.- Returns:
- the component value
-