Module is.codion.swing.common.ui
Class AbstractComponentBuilder<C extends JComponent,B extends ComponentBuilder<C,B>>
java.lang.Object
is.codion.swing.common.ui.component.builder.AbstractComponentBuilder<C,B>
- All Implemented Interfaces:
ComponentBuilder<C,
,B> Supplier<C>
- Direct Known Subclasses:
AbstractComponentValueBuilder
public abstract class AbstractComponentBuilder<C extends JComponent,B extends ComponentBuilder<C,B>>
extends Object
implements ComponentBuilder<C,B>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal B
background
(@Nullable Color background) final B
final C
build()
Builds a new component instance.final C
Builds a new component instance.final B
clientProperty
(Object key, @Nullable Object value) Adds an arbitrary key/value "client property" to the componentfinal B
componentListener
(ComponentListener componentListener) final B
componentOrientation
(@Nullable ComponentOrientation componentOrientation) protected C
configureComponent
(C component) protected abstract C
Creates the component.final B
enabled
(boolean enabled) Sets the enabled state of the component, for a dynamic enabled state useComponentBuilder.enabled(ObservableState)
.final B
enabled
(@Nullable ObservableState enabled) protected void
enableTransferFocusOnEnter
(C component, TransferFocusOnEnter transferFocusOnEnter) Enables focus transfer on Enter, override for special handlingprotected void
enableValidIndicator
(ValidIndicatorFactory validIndicatorFactory, C component, ObservableState valid) Enables a valid indicator on the given component, based on the given valid state instance using the givenValidIndicatorFactory
, override for special handling.final B
focusable
(boolean focusable) Sets the focusable state of the component, for a dynamic focusable state useComponentBuilder.focusable(ObservableState)
.final B
focusable
(@Nullable ObservableState focusable) final B
focusCycleRoot
(boolean focusCycleRoot) final B
focusListener
(FocusListener focusListener) final B
final B
foreground
(@Nullable Color foreground) final B
keyEvent
(KeyEvents.Builder keyEventBuilder) Enables the key event defined by the givenKeyEvents.Builder
on the component.final B
keyListener
(KeyListener keyListener) final B
label
(Consumer<LabelBuilder<String>> label) Is overridden byComponentBuilder.label(JLabel)
.final B
Clears any label builder previously configured viaComponentBuilder.label(Consumer)
.final B
maximumHeight
(int maximumHeight) final B
maximumSize
(@Nullable Dimension maximumSize) final B
maximumWidth
(int maximumWidth) final B
minimumHeight
(int minimumHeight) final B
minimumSize
(@Nullable Dimension minimumSize) final B
minimumWidth
(int minimumWidth) final B
mouseListener
(MouseListener mouseListener) final B
mouseMotionListener
(MouseMotionListener mouseMotionListener) final B
mouseWheelListener
(MouseWheelListener mouseWheelListener) final B
final B
final B
onSetVisible
(Consumer<C> onSetVisible) final B
opaque
(boolean opaque) final B
popupMenu
(@Nullable Function<C, JPopupMenu> popupMenu) final B
popupMenuControl
(Function<C, Control> popupMenuControl) final B
popupMenuControls
(Function<C, Controls> popupMenuControls) final B
preferredHeight
(int preferredHeight) final B
preferredSize
(@Nullable Dimension preferredSize) final B
preferredWidth
(int preferredWidth) final B
propertyChangeListener
(PropertyChangeListener propertyChangeListener) final B
propertyChangeListener
(String propertyName, PropertyChangeListener propertyChangeListener) final ScrollPaneBuilder
protected final B
self()
protected boolean
final B
toolTipText
(@Nullable Observable<String> toolTipText) OverridesComponentBuilder.toolTipText(String)
final B
toolTipText
(@Nullable String toolTipText) final B
transferFocusOnEnter
(boolean transferFocusOnEnter) Note that in case ofJTextArea
theInputEvent.CTRL_DOWN_MASK
modifier is added for transferring the focus forward.final B
transferFocusOnEnter
(TransferFocusOnEnter transferFocusOnEnter) Note that in case ofJTextArea
theInputEvent.CTRL_DOWN_MASK
modifier is added for transferring the focus forward.final B
transferHandler
(@Nullable TransferHandler transferHandler) final B
visible
(boolean visible) Sets the visible state of the component, for a dynamic visible state useComponentBuilder.visible(ObservableState)
.final B
visible
(@Nullable ObservableState visible) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface is.codion.swing.common.ui.component.builder.ComponentBuilder
get
-
Constructor Details
-
AbstractComponentBuilder
protected AbstractComponentBuilder()
-
-
Method Details
-
name
- Specified by:
name
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
name
- the name to assign to the component- Returns:
- this builder instance
- See Also:
-
label
Description copied from interface:ComponentBuilder
Clears any label builder previously configured viaComponentBuilder.label(Consumer)
.- Specified by:
label
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
label
- the label for the component- Returns:
- this builder instance
- See Also:
-
label
Description copied from interface:ComponentBuilder
Is overridden byComponentBuilder.label(JLabel)
.- Specified by:
label
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
label
- configures the component label builder- Returns:
- this builder instance
- See Also:
-
focusable
Description copied from interface:ComponentBuilder
Sets the focusable state of the component, for a dynamic focusable state useComponentBuilder.focusable(ObservableState)
. Overridden byComponentBuilder.focusable(ObservableState)
.- Specified by:
focusable
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
focusable
- the initial component focusability, default true- Returns:
- this builder instance
- See Also:
-
focusable
- Specified by:
focusable
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
focusable
- the state controlling the component focusable state- Returns:
- this builder instance
- See Also:
-
preferredHeight
- Specified by:
preferredHeight
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
preferredHeight
- the preferred component height- Returns:
- this builder instance
-
preferredWidth
- Specified by:
preferredWidth
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
preferredWidth
- the preferred component width- Returns:
- this builder instance
-
preferredSize
- Specified by:
preferredSize
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
preferredSize
- the preferred component size- Returns:
- this builder instance
- See Also:
-
maximumHeight
- Specified by:
maximumHeight
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
maximumHeight
- the maximum component height- Returns:
- this builder instance
-
maximumWidth
- Specified by:
maximumWidth
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
maximumWidth
- the maximum component width- Returns:
- this builder instance
-
maximumSize
- Specified by:
maximumSize
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
maximumSize
- the maximum component size- Returns:
- this builder instance
- See Also:
-
minimumHeight
- Specified by:
minimumHeight
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
minimumHeight
- the minimum component height- Returns:
- this builder instance
-
minimumWidth
- Specified by:
minimumWidth
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
minimumWidth
- the minimum component width- Returns:
- this builder instance
-
minimumSize
- Specified by:
minimumSize
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
minimumSize
- the minimum component size- Returns:
- this builder instance
- See Also:
-
border
- Specified by:
border
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
border
- the component border- Returns:
- this builder instance
- See Also:
-
transferFocusOnEnter
Description copied from interface:ComponentBuilder
Note that in case of
JTextArea
theInputEvent.CTRL_DOWN_MASK
modifier is added for transferring the focus forward.- Specified by:
transferFocusOnEnter
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
transferFocusOnEnter
- if true then the compnent transfers focus on enter (shift-enter for backwards)- Returns:
- this builder instance
-
transferFocusOnEnter
Description copied from interface:ComponentBuilder
Note that in case of
JTextArea
theInputEvent.CTRL_DOWN_MASK
modifier is added for transferring the focus forward.- Specified by:
transferFocusOnEnter
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
transferFocusOnEnter
- the transfer focus on enter to enable- Returns:
- this builder instance
-
enabled
Description copied from interface:ComponentBuilder
Sets the enabled state of the component, for a dynamic enabled state useComponentBuilder.enabled(ObservableState)
. Overridden byComponentBuilder.enabled(ObservableState)
.- Specified by:
enabled
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
enabled
- the enabled state- Returns:
- this builder instance
- See Also:
-
enabled
- Specified by:
enabled
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
enabled
- the state controlling the component enabled status- Returns:
- this builder instance
-
popupMenuControl
- Specified by:
popupMenuControl
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
popupMenuControl
- a function, receiving the component being built, providing the control to base a popup menu on- Returns:
- this builder instance
-
popupMenuControls
- Specified by:
popupMenuControls
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
popupMenuControls
- a function, receiving the component being built, providing the controls to base a popup menu on- Returns:
- this builder instance
-
popupMenu
- Specified by:
popupMenu
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
popupMenu
- a function, receiving the component being built, providing the popup menu- Returns:
- this builder instance
- See Also:
-
toolTipText
- Specified by:
toolTipText
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
toolTipText
- a static tool tip text- Returns:
- this builder instance
- See Also:
-
toolTipText
Description copied from interface:ComponentBuilder
OverridesComponentBuilder.toolTipText(String)
- Specified by:
toolTipText
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
toolTipText
- a dynamic tool tip text- Returns:
- this builder instance
- See Also:
-
font
- Specified by:
font
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
font
- the component font- Returns:
- this builder instance
- See Also:
-
foreground
- Specified by:
foreground
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
foreground
- the foreground color- Returns:
- this builder instance
- See Also:
-
background
- Specified by:
background
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
background
- the background color- Returns:
- this builder instance
- See Also:
-
opaque
- Specified by:
opaque
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
opaque
- true if the component should be opaque- Returns:
- this builder instance
- See Also:
-
visible
Description copied from interface:ComponentBuilder
Sets the visible state of the component, for a dynamic visible state useComponentBuilder.visible(ObservableState)
. Overridden byComponentBuilder.visible(ObservableState)
.- Specified by:
visible
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
visible
- the initial component visibility, default true- Returns:
- this builder instance
- See Also:
-
visible
- Specified by:
visible
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
visible
- the state controlling the component visible state- Returns:
- this builder instance
- See Also:
-
componentOrientation
- Specified by:
componentOrientation
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
componentOrientation
- the component orientation- Returns:
- this builder instance
- See Also:
-
keyEvent
Description copied from interface:ComponentBuilder
Enables the key event defined by the givenKeyEvents.Builder
on the component. Note that settingComponentBuilder.transferFocusOnEnter(boolean)
to true overrides any conflicting key event based onKeyEvent.VK_ENTER
added via this method.- Specified by:
keyEvent
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
keyEventBuilder
- a key event builder to enable on the component- Returns:
- this builder instance
-
clientProperty
Description copied from interface:ComponentBuilder
Adds an arbitrary key/value "client property" to the component- Specified by:
clientProperty
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
key
- the keyvalue
- the value- Returns:
- this builder instance
- See Also:
-
focusListener
- Specified by:
focusListener
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
focusListener
- the focus listener- Returns:
- this builder instance
- See Also:
-
mouseListener
- Specified by:
mouseListener
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
mouseListener
- the mouse listener- Returns:
- this builder instance
- See Also:
-
mouseMotionListener
- Specified by:
mouseMotionListener
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
mouseMotionListener
- the mouse motion listener- Returns:
- this builder instance
- See Also:
-
mouseWheelListener
- Specified by:
mouseWheelListener
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
mouseWheelListener
- the mouse wheel listener- Returns:
- this builder instance
- See Also:
-
keyListener
- Specified by:
keyListener
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
keyListener
- the key listener- Returns:
- this builder instance
- See Also:
-
componentListener
- Specified by:
componentListener
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
componentListener
- the component listener- Returns:
- this builder instance
- See Also:
-
propertyChangeListener
- Specified by:
propertyChangeListener
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
propertyChangeListener
- the property change listener- Returns:
- this builder instance
- See Also:
-
propertyChangeListener
public final B propertyChangeListener(String propertyName, PropertyChangeListener propertyChangeListener) - Specified by:
propertyChangeListener
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
propertyName
- the name of the property to listen forpropertyChangeListener
- the property change listener- Returns:
- this builder instance
- See Also:
-
transferHandler
- Specified by:
transferHandler
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
transferHandler
- the transfer handler- Returns:
- this builder instance
- See Also:
-
focusCycleRoot
- Specified by:
focusCycleRoot
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
focusCycleRoot
- true if the component should be the root of a focus traversal cycle- Returns:
- this builder instance
- See Also:
-
onSetVisible
- Specified by:
onSetVisible
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
onSetVisible
- called when the component is made visible for the first time- Returns:
- this builder instance
-
scrollPane
- Specified by:
scrollPane
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Returns:
- a
ScrollPaneBuilder
using this component as the view
-
onBuild
- Specified by:
onBuild
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
onBuild
- called when the component has been built.- Returns:
- this builder instance
-
build
Description copied from interface:ComponentBuilder
Builds a new component instance.- Specified by:
build
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Returns:
- the component
-
build
Description copied from interface:ComponentBuilder
Builds a new component instance.- Specified by:
build
in interfaceComponentBuilder<C extends JComponent,
B extends ComponentBuilder<C, B>> - Parameters:
onBuild
- called after the component is built.- Returns:
- the component
-
createComponent
Creates the component.- Returns:
- a new component instance
-
supportsNull
protected boolean supportsNull()- Returns:
- true if this component can be linked with a nullable value
-
enableTransferFocusOnEnter
Enables focus transfer on Enter, override for special handling- Parameters:
component
- the componenttransferFocusOnEnter
- the transfer focus on enter to enable
-
enableValidIndicator
protected void enableValidIndicator(ValidIndicatorFactory validIndicatorFactory, C component, ObservableState valid) Enables a valid indicator on the given component, based on the given valid state instance using the givenValidIndicatorFactory
, override for special handling.- Parameters:
validIndicatorFactory
- theValidIndicatorFactory
to usecomponent
- the componentvalid
- the valid state to indicate
-
self
-
configureComponent
-