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 BancestorListener(AncestorListener ancestorListener) final Bbackground(@Nullable Color background) final Bfinal Cbuild()Builds a new component instance.final CBuilds a new component instance.final BclientProperty(Object key, @Nullable Object value) Adds an arbitrary key/value "client property" to the componentfinal BcomponentListener(ComponentListener componentListener) final BcomponentOrientation(@Nullable ComponentOrientation componentOrientation) protected CconfigureComponent(C component) protected abstract CCreates the component.final Benabled(boolean enabled) Sets the enabled state of the component, for a dynamic enabled state useComponentBuilder.enabled(ObservableState).final Benabled(@Nullable ObservableState enabled) protected voidenableModifiedIndicator(ModifiedIndicatorFactory modifiedIndicatorFactory, C component, ObservableState modified) Enables a modified indicator on the given component, based on the given modified state instance using the givenModifiedIndicatorFactory, override for composite components or special handling.protected voidenableTransferFocusOnEnter(C component, TransferFocusOnEnter transferFocusOnEnter) Enables focus transfer on Enter, override for composite components or special handlingprotected voidenableValidIndicator(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 composite components or special handling.final Bfocusable(boolean focusable) Sets the focusable state of the component, for a dynamic focusable state useComponentBuilder.focusable(ObservableState).final Bfocusable(@Nullable ObservableState focusable) final BfocusCycleRoot(boolean focusCycleRoot) final BfocusListener(FocusListener focusListener) final BOverridesComponentBuilder.font(UnaryOperator).final Bfont(UnaryOperator<Font> font) Derives the component font from its default font.final Bforeground(@Nullable Color foreground) final BhierarchyListener(HierarchyListener hierarchyListener) final BkeyEvent(KeyEvents.Builder keyEventBuilder) Enables the key event defined by the givenKeyEvents.Builderon the component.final BkeyListener(KeyListener keyListener) label()final Blabel(Consumer<LabelBuilder<String>> label) Is overridden by subsequent calls toComponentBuilder.label(JLabel).final BIs overridden by subsequent calls toComponentBuilder.label(Consumer).final BmaximumHeight(int maximumHeight) final BmaximumSize(@Nullable Dimension maximumSize) final BmaximumWidth(int maximumWidth) final BminimumHeight(int minimumHeight) final BminimumSize(@Nullable Dimension minimumSize) final BminimumWidth(int minimumWidth) final BmouseListener(MouseListener mouseListener) final BmouseMotionListener(MouseMotionListener mouseMotionListener) final BmouseWheelListener(MouseWheelListener mouseWheelListener) final Bfinal Bfinal BonSetVisible(Consumer<C> onSetVisible) final Bopaque(boolean opaque) final BpopupControl(Function<C, Control> popupMenuControl) final BpopupControls(BiConsumer<C, ControlsBuilder> popupControls) UseControlsBuilder.removeAll()in order to clear any previously added controls.final BpopupControls(Function<C, Controls> popupMenuControls) final BpopupMenu(@Nullable Function<C, JPopupMenu> popupMenu) final BpreferredHeight(int preferredHeight) final BpreferredSize(@Nullable Dimension preferredSize) final BpreferredWidth(int preferredWidth) final BpropertyChangeListener(PropertyChangeListener propertyChangeListener) final BpropertyChangeListener(String propertyName, PropertyChangeListener propertyChangeListener) final ScrollPaneBuilderprotected final Bself()protected booleanfinal BtoolTipText(@Nullable Observable<String> toolTipText) OverridesComponentBuilder.toolTipText(String)final BtoolTipText(@Nullable String toolTipText) final BtransferFocusOnEnter(boolean transferFocusOnEnter) Note that in case ofJTextAreatheKeyEvents.MENU_SHORTCUT_MASKmodifier is added for transferring the focus forward.final BtransferFocusOnEnter(TransferFocusOnEnter transferFocusOnEnter) Note that in case ofJTextAreatheKeyEvents.MENU_SHORTCUT_MASKmodifier is added for transferring the focus forward.final BtransferHandler(@Nullable TransferHandler transferHandler) final Bvisible(boolean visible) Sets the visible state of the component, for a dynamic visible state useComponentBuilder.visible(ObservableState).final Bvisible(@Nullable ObservableState visible) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface is.codion.swing.common.ui.component.builder.ComponentBuilder
get
-
Constructor Details
-
AbstractComponentBuilder
protected AbstractComponentBuilder()
-
-
Method Details
-
name
- Specified by:
namein 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:ComponentBuilderIs overridden by subsequent calls toComponentBuilder.label(Consumer).- Specified by:
labelin 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:ComponentBuilderIs overridden by subsequent calls toComponentBuilder.label(JLabel).- Specified by:
labelin 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:ComponentBuilderSets the focusable state of the component, for a dynamic focusable state useComponentBuilder.focusable(ObservableState). Overridden byComponentBuilder.focusable(ObservableState).- Specified by:
focusablein 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:
focusablein 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:
preferredHeightin interfaceComponentBuilder<C extends JComponent,B extends ComponentBuilder<C, B>> - Parameters:
preferredHeight- the preferred component height- Returns:
- this builder instance
-
preferredWidth
- Specified by:
preferredWidthin interfaceComponentBuilder<C extends JComponent,B extends ComponentBuilder<C, B>> - Parameters:
preferredWidth- the preferred component width- Returns:
- this builder instance
-
preferredSize
- Specified by:
preferredSizein interfaceComponentBuilder<C extends JComponent,B extends ComponentBuilder<C, B>> - Parameters:
preferredSize- the preferred component size- Returns:
- this builder instance
- See Also:
-
maximumHeight
- Specified by:
maximumHeightin interfaceComponentBuilder<C extends JComponent,B extends ComponentBuilder<C, B>> - Parameters:
maximumHeight- the maximum component height- Returns:
- this builder instance
-
maximumWidth
- Specified by:
maximumWidthin interfaceComponentBuilder<C extends JComponent,B extends ComponentBuilder<C, B>> - Parameters:
maximumWidth- the maximum component width- Returns:
- this builder instance
-
maximumSize
- Specified by:
maximumSizein interfaceComponentBuilder<C extends JComponent,B extends ComponentBuilder<C, B>> - Parameters:
maximumSize- the maximum component size- Returns:
- this builder instance
- See Also:
-
minimumHeight
- Specified by:
minimumHeightin interfaceComponentBuilder<C extends JComponent,B extends ComponentBuilder<C, B>> - Parameters:
minimumHeight- the minimum component height- Returns:
- this builder instance
-
minimumWidth
- Specified by:
minimumWidthin interfaceComponentBuilder<C extends JComponent,B extends ComponentBuilder<C, B>> - Parameters:
minimumWidth- the minimum component width- Returns:
- this builder instance
-
minimumSize
- Specified by:
minimumSizein interfaceComponentBuilder<C extends JComponent,B extends ComponentBuilder<C, B>> - Parameters:
minimumSize- the minimum component size- Returns:
- this builder instance
- See Also:
-
border
- Specified by:
borderin 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:ComponentBuilderNote that in case of
JTextAreatheKeyEvents.MENU_SHORTCUT_MASKmodifier is added for transferring the focus forward.- Specified by:
transferFocusOnEnterin 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:ComponentBuilderNote that in case of
JTextAreatheKeyEvents.MENU_SHORTCUT_MASKmodifier is added for transferring the focus forward.- Specified by:
transferFocusOnEnterin 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:ComponentBuilderSets the enabled state of the component, for a dynamic enabled state useComponentBuilder.enabled(ObservableState). Overridden byComponentBuilder.enabled(ObservableState).- Specified by:
enabledin interfaceComponentBuilder<C extends JComponent,B extends ComponentBuilder<C, B>> - Parameters:
enabled- the enabled state- Returns:
- this builder instance
- See Also:
-
enabled
- Specified by:
enabledin interfaceComponentBuilder<C extends JComponent,B extends ComponentBuilder<C, B>> - Parameters:
enabled- the state controlling the component enabled status- Returns:
- this builder instance
-
popupControls
Description copied from interface:ComponentBuilderUseControlsBuilder.removeAll()in order to clear any previously added controls.- Specified by:
popupControlsin interfaceComponentBuilder<C extends JComponent,B extends ComponentBuilder<C, B>> - Parameters:
popupControls- a function, receiving the component being built and theControlsBuilderon which to base the popup menu.- Returns:
- this builder instance
- See Also:
-
popupControl
- Specified by:
popupControlin interfaceComponentBuilder<C extends JComponent,B extends ComponentBuilder<C, B>> - Parameters:
popupMenuControl- a function, receiving the component being built, providing a control to add to the popup menu- Returns:
- this builder instance
-
popupControls
- Specified by:
popupControlsin interfaceComponentBuilder<C extends JComponent,B extends ComponentBuilder<C, B>> - Parameters:
popupMenuControls- a function, receiving the component being built, providing controls to add to the popup menu- Returns:
- this builder instance
-
popupMenu
Description copied from interface:ComponentBuilderOverridesComponentBuilder.popupControls(Function),ComponentBuilder.popupControls(BiConsumer)andComponentBuilder.popupControl(Function)- Specified by:
popupMenuin 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:
toolTipTextin 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:ComponentBuilderOverridesComponentBuilder.toolTipText(String)- Specified by:
toolTipTextin interfaceComponentBuilder<C extends JComponent,B extends ComponentBuilder<C, B>> - Parameters:
toolTipText- a dynamic tool tip text- Returns:
- this builder instance
- See Also:
-
font
Description copied from interface:ComponentBuilderOverridesComponentBuilder.font(UnaryOperator).- Specified by:
fontin interfaceComponentBuilder<C extends JComponent,B extends ComponentBuilder<C, B>> - Parameters:
font- the component font- Returns:
- this builder instance
- See Also:
-
font
Description copied from interface:ComponentBuilderDerives the component font from its default font. The operator is applied to the component's default font during build.Is overridden by a font set via
ComponentBuilder.font(Font).- Specified by:
fontin interfaceComponentBuilder<C extends JComponent,B extends ComponentBuilder<C, B>> - Parameters:
font- provides the font to use, given the component's default font- Returns:
- this builder instance
- See Also:
-
foreground
- Specified by:
foregroundin interfaceComponentBuilder<C extends JComponent,B extends ComponentBuilder<C, B>> - Parameters:
foreground- the foreground color- Returns:
- this builder instance
- See Also:
-
background
- Specified by:
backgroundin interfaceComponentBuilder<C extends JComponent,B extends ComponentBuilder<C, B>> - Parameters:
background- the background color- Returns:
- this builder instance
- See Also:
-
opaque
- Specified by:
opaquein 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:ComponentBuilderSets the visible state of the component, for a dynamic visible state useComponentBuilder.visible(ObservableState). Overridden byComponentBuilder.visible(ObservableState).- Specified by:
visiblein 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:
visiblein 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:
componentOrientationin 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:ComponentBuilderEnables the key event defined by the givenKeyEvents.Builderon the component. Note that settingComponentBuilder.transferFocusOnEnter(boolean)to true overrides any conflicting key event based onKeyEvent.VK_ENTERadded via this method.- Specified by:
keyEventin 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:ComponentBuilderAdds an arbitrary key/value "client property" to the component- Specified by:
clientPropertyin interfaceComponentBuilder<C extends JComponent,B extends ComponentBuilder<C, B>> - Parameters:
key- the keyvalue- the value- Returns:
- this builder instance
- See Also:
-
focusListener
- Specified by:
focusListenerin interfaceComponentBuilder<C extends JComponent,B extends ComponentBuilder<C, B>> - Parameters:
focusListener- the focus listener- Returns:
- this builder instance
- See Also:
-
mouseListener
- Specified by:
mouseListenerin interfaceComponentBuilder<C extends JComponent,B extends ComponentBuilder<C, B>> - Parameters:
mouseListener- the mouse listener- Returns:
- this builder instance
- See Also:
-
mouseMotionListener
- Specified by:
mouseMotionListenerin interfaceComponentBuilder<C extends JComponent,B extends ComponentBuilder<C, B>> - Parameters:
mouseMotionListener- the mouse motion listener- Returns:
- this builder instance
- See Also:
-
mouseWheelListener
- Specified by:
mouseWheelListenerin interfaceComponentBuilder<C extends JComponent,B extends ComponentBuilder<C, B>> - Parameters:
mouseWheelListener- the mouse wheel listener- Returns:
- this builder instance
- See Also:
-
keyListener
- Specified by:
keyListenerin interfaceComponentBuilder<C extends JComponent,B extends ComponentBuilder<C, B>> - Parameters:
keyListener- the key listener- Returns:
- this builder instance
- See Also:
-
componentListener
- Specified by:
componentListenerin interfaceComponentBuilder<C extends JComponent,B extends ComponentBuilder<C, B>> - Parameters:
componentListener- the component listener- Returns:
- this builder instance
- See Also:
-
ancestorListener
- Specified by:
ancestorListenerin interfaceComponentBuilder<C extends JComponent,B extends ComponentBuilder<C, B>> - Parameters:
ancestorListener- the ancestor listener- Returns:
- this builder instance
- See Also:
-
hierarchyListener
- Specified by:
hierarchyListenerin interfaceComponentBuilder<C extends JComponent,B extends ComponentBuilder<C, B>> - Parameters:
hierarchyListener- the hierarchy listener- Returns:
- this builder instance
- See Also:
-
propertyChangeListener
- Specified by:
propertyChangeListenerin 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:
propertyChangeListenerin 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:
transferHandlerin interfaceComponentBuilder<C extends JComponent,B extends ComponentBuilder<C, B>> - Parameters:
transferHandler- the transfer handler- Returns:
- this builder instance
- See Also:
-
focusCycleRoot
- Specified by:
focusCycleRootin 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:
onSetVisiblein 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:
scrollPanein interfaceComponentBuilder<C extends JComponent,B extends ComponentBuilder<C, B>> - Returns:
- a
ScrollPaneBuilderusing this component as the view
-
onBuild
- Specified by:
onBuildin 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:ComponentBuilderBuilds a new component instance.- Specified by:
buildin interfaceComponentBuilder<C extends JComponent,B extends ComponentBuilder<C, B>> - Returns:
- the component
-
build
Description copied from interface:ComponentBuilderBuilds a new component instance.- Specified by:
buildin 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 composite components or 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 composite components or special handling.- Parameters:
validIndicatorFactory- theValidIndicatorFactoryto usecomponent- the componentvalid- the valid state to indicate
-
enableModifiedIndicator
protected void enableModifiedIndicator(ModifiedIndicatorFactory modifiedIndicatorFactory, C component, ObservableState modified) Enables a modified indicator on the given component, based on the given modified state instance using the givenModifiedIndicatorFactory, override for composite components or special handling.- Parameters:
modifiedIndicatorFactory- theModifiedIndicatorFactoryto usecomponent- the componentmodified- the modified state to indicate
-
self
-
label
- Returns:
- the label set via
label(JLabel)orlabel(Consumer), or null if none has been set
-
configureComponent
-