public abstract class AbstractComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>> extends Object implements ComponentBuilder<T,C,B>
TRANSFER_FOCUS_ON_ENTER
Modifier | Constructor and Description |
---|---|
protected |
AbstractComponentBuilder() |
protected |
AbstractComponentBuilder(Value<T> linkedValue)
Note that when a linked value is set via the constructor,
it is considered locked and cannot be changed.
|
Modifier and Type | Method and Description |
---|---|
B |
background(Color background) |
B |
border(Border border) |
C |
build()
Builds and returns the component, note that subsequent calls return the same component until
ComponentBuilder.clear() has been called. |
C |
build(Consumer<C> onBuild)
Builds and returns the component, note that subsequent calls return the same component until
ComponentBuilder.clear() has been called. |
ComponentValue<T,C> |
buildComponentValue()
Builds and returns the component value, note that subsequent calls return the same component value until
ComponentBuilder.clear() has been called. |
B |
clear()
Clears this builder so that it builds a new instance on next call to
ComponentBuilder.build() or ComponentBuilder.buildComponentValue() . |
B |
clientProperty(Object key,
Object value)
Adds an arbitrary key/value "client property" to the component
|
B |
componentListener(ComponentListener componentListener) |
B |
componentOrientation(ComponentOrientation componentOrientation) |
protected abstract C |
createComponent()
Creates the component.
|
protected abstract ComponentValue<T,C> |
createComponentValue(C component)
Creates the component value
|
B |
enabled(boolean enabled)
Sets the enabled state of the component, for a dynamic enabled state use
ComponentBuilder.enabledState(StateObserver) . |
B |
enabledState(StateObserver enabledState) |
protected void |
enableTransferFocusOnEnter(C component)
Enables focus transfer on Enter, override for special handling
|
B |
focusable(boolean focusable) |
B |
focusListener(FocusListener focusListener) |
B |
font(Font font) |
B |
foreground(Color foreground) |
B |
initialValue(T initialValue)
Sets the initial value for the component, overridden by
ComponentBuilder.linkedValue(Value) . |
B |
keyEvent(KeyEvents.Builder keyEventBuilder)
Enables the key event defined by the given
KeyEvents.Builder on the component. |
B |
keyListener(KeyListener keyListener) |
B |
label(JLabel label) |
B |
linkedValue(Value<T> linkedValue)
Creates a bidirectional link to the given value.
|
B |
linkedValueObserver(ValueObserver<T> linkedValueObserver)
Creates a read-only link to the given
ValueObserver . |
B |
maximumHeight(int maximumHeight) |
B |
maximumSize(Dimension maximumSize) |
B |
maximumWidth(int maximumWidth) |
B |
minimumHeight(int minimumHeight) |
B |
minimumSize(Dimension minimumSize) |
B |
minimumWidth(int minimumWidth) |
B |
mouseListener(MouseListener mouseListener) |
B |
mouseMotionListener(MouseMotionListener mouseMotionListener) |
B |
mouseWheelListener(MouseWheelListener mouseWheelListener) |
B |
onBuild(Consumer<C> onBuild) |
B |
onSetVisible(Consumer<C> onSetVisible) |
B |
opaque(boolean opaque) |
B |
popupMenu(JPopupMenu popupMenu) |
B |
popupMenuControl(Control popupMenuControl) |
B |
popupMenuControls(Controls popupMenuControls) |
B |
preferredHeight(int preferredHeight) |
B |
preferredSize(Dimension preferredSize) |
B |
preferredWidth(int preferredWidth) |
ScrollPaneBuilder |
scrollPane() |
protected abstract void |
setInitialValue(C component,
T initialValue)
Sets the initial value in the component, only called for non-null values.
|
B |
toolTipText(String toolTipText) |
B |
transferFocusOnEnter(boolean transferFocusOnEnter)
Note that for JTextArea CTRL is added to move focus forward and CTRL + SHIFT to move it backwards
|
B |
transferHandler(TransferHandler transferHandler) |
B |
validator(Value.Validator<T> validator) |
public final B label(JLabel label)
label
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
label
- the label for the componentJLabel.setLabelFor(Component)
public final B focusable(boolean focusable)
focusable
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
focusable
- false if the component should not be focusableComponent.setFocusable(boolean)
public final B preferredHeight(int preferredHeight)
preferredHeight
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
preferredHeight
- the preferred component heightpublic final B preferredWidth(int preferredWidth)
preferredWidth
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
preferredWidth
- the preferred component widthpublic final B preferredSize(Dimension preferredSize)
preferredSize
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
preferredSize
- the preferred component sizeJComponent.setPreferredSize(Dimension)
public final B maximumHeight(int maximumHeight)
maximumHeight
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
maximumHeight
- the maximum component heightpublic final B maximumWidth(int maximumWidth)
maximumWidth
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
maximumWidth
- the maximum component widthpublic final B maximumSize(Dimension maximumSize)
maximumSize
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
maximumSize
- the maximum component sizeJComponent.setMaximumSize(Dimension)
public final B minimumHeight(int minimumHeight)
minimumHeight
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
minimumHeight
- the minimum component heightpublic final B minimumWidth(int minimumWidth)
minimumWidth
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
minimumWidth
- the minimum component widthpublic final B minimumSize(Dimension minimumSize)
minimumSize
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
minimumSize
- the minimum component sizeJComponent.setMinimumSize(Dimension)
public final B border(Border border)
border
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
border
- the component borderJComponent.setBorder(Border)
public final B transferFocusOnEnter(boolean transferFocusOnEnter)
ComponentBuilder
transferFocusOnEnter
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
transferFocusOnEnter
- if true then the text field transfer focus on enter (shift-enter for backwards)public final B enabled(boolean enabled)
ComponentBuilder
ComponentBuilder.enabledState(StateObserver)
.
Overridden by ComponentBuilder.enabledState(StateObserver)
.enabled
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
enabled
- the enabled stateJComponent.setEnabled(boolean)
public final B enabledState(StateObserver enabledState)
enabledState
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
enabledState
- the state controlling the component enabled statuspublic final B popupMenuControl(Control popupMenuControl)
popupMenuControl
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
popupMenuControl
- the control to base a popup menu onpublic final B popupMenuControls(Controls popupMenuControls)
popupMenuControls
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
popupMenuControls
- the controls to base a popup menu onpublic final B popupMenu(JPopupMenu popupMenu)
popupMenu
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
popupMenu
- the popup menuJComponent.setComponentPopupMenu(JPopupMenu)
public final B toolTipText(String toolTipText)
toolTipText
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
toolTipText
- the tool tip textJComponent.setToolTipText(String)
public final B font(Font font)
font
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
font
- the component fontJComponent.setFont(Font)
public final B foreground(Color foreground)
foreground
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
foreground
- the foreground colorJComponent.setForeground(Color)
public final B background(Color background)
background
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
background
- the background colorJComponent.setBackground(Color)
public final B opaque(boolean opaque)
opaque
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
opaque
- true if the component should be opaqueJComponent.setOpaque(boolean)
public final B componentOrientation(ComponentOrientation componentOrientation)
componentOrientation
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
componentOrientation
- the component orientationComponent.setComponentOrientation(ComponentOrientation)
public final B validator(Value.Validator<T> validator)
validator
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
validator
- the validator to usepublic final B keyEvent(KeyEvents.Builder keyEventBuilder)
ComponentBuilder
KeyEvents.Builder
on the component.
Note that setting ComponentBuilder.transferFocusOnEnter(boolean)
to true overrides
any conflicting key event based on KeyEvent.VK_ENTER
added via this method.keyEvent
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
keyEventBuilder
- a key event builder to enable on the componentpublic final B clientProperty(Object key, Object value)
ComponentBuilder
clientProperty
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
key
- the keyvalue
- the valueJComponent.putClientProperty(Object, Object)
public final B focusListener(FocusListener focusListener)
focusListener
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
focusListener
- the focus listenerComponent.addFocusListener(FocusListener)
public final B mouseListener(MouseListener mouseListener)
mouseListener
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
mouseListener
- the mouse listenerComponent.addMouseListener(MouseListener)
public final B mouseMotionListener(MouseMotionListener mouseMotionListener)
mouseMotionListener
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
mouseMotionListener
- the mouse motion listenerComponent.addMouseMotionListener(MouseMotionListener)
public final B mouseWheelListener(MouseWheelListener mouseWheelListener)
mouseWheelListener
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
mouseWheelListener
- the mouse wheel listenerComponent.addMouseWheelListener(MouseWheelListener)
public final B keyListener(KeyListener keyListener)
keyListener
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
keyListener
- the key listenerComponent.addKeyListener(KeyListener)
public final B componentListener(ComponentListener componentListener)
componentListener
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
componentListener
- the component listenerComponent.addComponentListener(ComponentListener)
public final B transferHandler(TransferHandler transferHandler)
transferHandler
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
transferHandler
- the transfer handlerJComponent.setTransferHandler(TransferHandler)
public final B onSetVisible(Consumer<C> onSetVisible)
onSetVisible
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
onSetVisible
- called when the component is made visible for the first timepublic final B linkedValue(Value<T> linkedValue)
ComponentBuilder
linkedValue
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
linkedValue
- a value to link to the component valuepublic final B linkedValueObserver(ValueObserver<T> linkedValueObserver)
ComponentBuilder
ValueObserver
.linkedValueObserver
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
linkedValueObserver
- a value to link to the component valuepublic final B initialValue(T initialValue)
ComponentBuilder
ComponentBuilder.linkedValue(Value)
.
Note that null is not explicitely set, the component is assumed to represent the null
value right after it's been created.initialValue
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
initialValue
- the initial valuepublic final ScrollPaneBuilder scrollPane()
scrollPane
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
ScrollPaneBuilder
using this component as the viewpublic final B onBuild(Consumer<C> onBuild)
onBuild
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
onBuild
- called when the component has been built, before any values are linked, not called on subsequent
calls until ComponentBuilder.clear()
has been called.public final C build()
ComponentBuilder
ComponentBuilder.clear()
has been called.build
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
public final C build(Consumer<C> onBuild)
ComponentBuilder
ComponentBuilder.clear()
has been called.build
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
onBuild
- called after the first call when the component is built, before any values are linked, not called on subsequent calls.public final ComponentValue<T,C> buildComponentValue()
ComponentBuilder
ComponentBuilder.clear()
has been called.buildComponentValue
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
public final B clear()
ComponentBuilder
ComponentBuilder.build()
or ComponentBuilder.buildComponentValue()
.clear
in interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
protected abstract C createComponent()
protected abstract ComponentValue<T,C> createComponentValue(C component)
component
- the componentprotected abstract void setInitialValue(C component, T initialValue)
component
- the componentinitialValue
- the initial value, not nullprotected void enableTransferFocusOnEnter(C component)
component
- the component