Package swingtree
Class UIForTabbedPane<P extends JTabbedPane>
- Type Parameters:
P
- The type of theJTabbedPane
instance that this builder node configures.
public final class UIForTabbedPane<P extends JTabbedPane>
extends UIForAnySwing<UIForTabbedPane<P>,P>
A SwingTree builder node designed for configuring
JTabbedPane
instances.-
Method Summary
Modifier and TypeMethodDescriptionprotected UIForTabbedPane
<P> _newBuilderWithState
(swingtree.BuilderState<P> newState) An internal wither method which creates a new builder instance with the providedBuilderState
stored inside it.protected swingtree.BuilderState
<P> _state()
Returns the state of the builder, which is a container for the wrapped component as well as it's type and currentEventProcessor
.final UIForTabbedPane
<P> Adds a tab to the tabbed pane based on the givenTab
configuration.<M> UIForTabbedPane
<P> addAll
(sprouts.Val<sprouts.Tuple<M>> tabModels, TabSupplier<M> tabSupplier) Dynamically generates tabs for items in aTuple
Val
and automatically updates them when the items change.<M> UIForTabbedPane
<P> addAll
(sprouts.Vals<M> tabModels, TabSupplier<M> tabSupplier) Dynamically generates tabs for items in aVals
list and automatically updates them when the items change.final UIForTabbedPane
<P> onChange
(sprouts.Action<ComponentDelegate<P, ChangeEvent>> onChange) Adds anAction
to the underlyingJTabbedPane
through anChangeListener
, which will be called when the state of the tabbed pane changes.final UIForTabbedPane
<P> onTabMouseClick
(sprouts.Action<TabDelegate> onClick) Adds an action to be performed when a mouse click is detected on a tab.final UIForTabbedPane
<P> onTabMouseEnter
(sprouts.Action<TabDelegate> onEnter) Adds an action to be performed when a mouse enter is detected on a tab.final UIForTabbedPane
<P> onTabMouseExit
(sprouts.Action<TabDelegate> onExit) Adds an action to be performed when a mouse exit is detected on a tab.final UIForTabbedPane
<P> onTabMousePress
(sprouts.Action<TabDelegate> onPress) Adds an action to be performed when a mouse press is detected on a tab.final UIForTabbedPane
<P> onTabMouseRelease
(sprouts.Action<TabDelegate> onRelease) Adds an action to be performed when a mouse release is detected on a tab.final UIForTabbedPane
<P> withOverflowPolicy
(sprouts.Val<UI.OverflowPolicy> policy) Binds the supplied enum property to the overflow policy of the tabbed pane.final UIForTabbedPane
<P> withOverflowPolicy
(UI.OverflowPolicy policy) Defines the overflow policy based on the givenUI.OverflowPolicy
enum, which maps directly to theJTabbedPane.setTabLayoutPolicy(int)
method.final UIForTabbedPane
<P> withSelectedIndex
(int index) Sets the selected tab based on the given index.final UIForTabbedPane
<P> withSelectedIndex
(sprouts.Val<Integer> index) Dynamically sets the selected tab based on the given index property.final UIForTabbedPane
<P> withSelectedIndex
(sprouts.Var<Integer> index) Binds the given index property to the selection index of the tabbed pane, which means that when the index property changes, the selected tab will change accordingly and when the user selects a different tab, the index property will be updated accordingly.final UIForTabbedPane
<P> withTabPlacementAt
(sprouts.Val<UI.Side> side) Binds the supplied property to the tab placement of the tabbed pane.final UIForTabbedPane
<P> withTabPlacementAt
(UI.Side side) Defines the tab placement side based on the givenUI.Side
enum, which maps directly to theJTabbedPane.setTabPlacement(int)
method.Methods inherited from class swingtree.UIForAnySwing
_addComponentTo, _addViewableProps, _addViewableProps, _isUndefinedColor, _isUndefinedFont, _setBackground, _setEnabled, _setMinHeight, _setMinWidth, _setPrefWidth, add, add, add, add, add, add, add, add, add, add, addAll, addAll, addAll, addAll, addAll, addAll, doUpdates, group, group, id, id, isEnabledIf, isEnabledIf, isEnabledIf, isEnabledIfNot, isEnabledIfNot, isEnabledIfNot, isFocusableIf, isFocusableIf, isFocusableIf, isFocusableIfNot, isFocusableIfNot, isFocusableIfNot, isValidIf, isVisibleIf, isVisibleIf, isVisibleIf, isVisibleIfNot, isVisibleIfNot, isVisibleIfNot, makeFocused, makeNonOpaque, makeOpaque, on, on, onCharTyped, onFocusGain, onFocusLoss, onHidden, onKeyPress, onKeyRelease, onKeyTyped, onMouseClick, onMouseDrag, onMouseEnter, onMouseEnter, onMouseEnterGreedy, onMouseExit, onMouseExit, onMouseExitGreedy, onMouseMove, onMousePress, onMouseRelease, onMouseWheelDown, onMouseWheelMove, onMouseWheelUp, onMoved, onPressed, onRelease, onResize, onShown, onTyped, onTyped, onView, withBackground, withBackground, withBackgroundColor, withBackgroundIf, withBackgroundIf, withBackgroundIf, withBackgroundIf, withBorder, withBorder, withBorderTitled, withBorderTitled, withBoxLayout, withCompoundBorder, withCompoundBorderTitled, withCursor, withCursor, withCursorIf, withCursorIf, withDragAway, withDropSite, withEmptyBorder, withEmptyBorder, withEmptyBorder, withEmptyBorder, withEmptyBorderTitled, withEmptyBorderTitled, withEmptyBorderTitled, withEmptyBorderTitled, withEmptyBorderTitled, withEmptyBorderTitled, withEmptyBorderTitled, withEmptyBorderTitled, withFlowLayout, withFlowLayout, withFlowLayout, withForeground, withForeground, withForegroundColor, withForegroundIf, withForegroundIf, withForegroundIf, withForegroundIf, withGridBagLayout, withGridLayout, withGridLayout, withGridLayout, withHeight, withHeight, withHeightExactly, withHeightExactly, withLayout, withLayout, withLayout, withLayout, withLayout, withLayout, withLayout, withLayout, withLayout, withLayout, withLayout, withLayout, withLineBorder, withLineBorder, withLineBorder, withLineBorderTitled, withLineBorderTitled, withLineBorderTitled, withLineBorderTitled, withMatteBorder, withMatteBorder, withMatteBorder, withMatteBorderTitled, withMatteBorderTitled, withMatteBorderTitled, withMaxHeight, withMaxHeight, withMaxSize, withMaxSize, withMaxSize, withMaxSize, withMaxSize, withMaxWidth, withMaxWidth, withMinHeight, withMinHeight, withMinSize, withMinSize, withMinSize, withMinSize, withMinSize, withMinWidth, withMinWidth, withPrefHeight, withPrefHeight, withPrefSize, withPrefSize, withPrefSize, withPrefSize, withPrefSize, withPrefWidth, withPrefWidth, withProperty, withRepaintOn, withRepaintOn, withRepaintOn, withRepaintOn, withRepaintOn, withRepaintOn, withRoundedLineBorder, withRoundedLineBorder, withRoundedLineBorder, withRoundedLineBorder, withRoundedLineBorderTitled, withRoundedLineBorderTitled, withRoundedLineBorderTitled, withRoundedLineBorderTitled, withRoundedLineBorderTitled, withRoundedLineBorderTitled, withRoundedLineBorderTitled, withSize, withSize, withSize, withSize, withSizeExactly, withSizeExactly, withSizeExactly, withSizeExactly, withStyle, withTooltip, withTooltip, withTransitionalStyle, withTransitoryStyle, withWidth, withWidth, withWidthExactly, withWidthExactly
Methods inherited from class swingtree.UIForAnything
_addBuildersTo, _addBuilderTo, _addComponentsTo, _disposeState, _onShow, _onShow, _runInApp, _runInApp, _runInUI, _this, _with, _withOnShow, _withOnShow, add, add, add, add, apply, applyIf, applyIfPresent, component, equals, get, getComponent, getType, hashCode, peek, toString
-
Method Details
-
_state
Description copied from class:UIForAnything
Returns the state of the builder, which is a container for the wrapped component as well as it's type and currentEventProcessor
.- Specified by:
_state
in classUIForAnything<UIForTabbedPane<P extends JTabbedPane>,
P extends JTabbedPane, JComponent> - Returns:
- The state of the builder.
-
_newBuilderWithState
Description copied from class:UIForAnything
An internal wither method which creates a new builder instance with the providedBuilderState
stored inside it.- Specified by:
_newBuilderWithState
in classUIForAnything<UIForTabbedPane<P extends JTabbedPane>,
P extends JTabbedPane, JComponent> - Parameters:
newState
- The new state which should be stored inside the new builder instance.- Returns:
- A new builder instance with the provided state stored inside it.
-
onTabMouseClick
Adds an action to be performed when a mouse click is detected on a tab. The action will receive aTabDelegate
instance which not only delegates the current tabbed pane and mouse event, but also tells the action which tab was clicked and whether the clicked tab is selected.- Parameters:
onClick
- The action to be performed when a tab is clicked.- Returns:
- This builder node.
- Throws:
NullPointerException
- if the given action is null.
-
onTabMousePress
Adds an action to be performed when a mouse press is detected on a tab. The action will receive aTabDelegate
instance which not only delegates the current tabbed pane and mouse event, but also tells the action which tab was pressed and whether the pressed tab is selected.- Parameters:
onPress
- The action to be performed when a tab is pressed.- Returns:
- This builder node.
- Throws:
NullPointerException
- if the given action is null.
-
onTabMouseRelease
Adds an action to be performed when a mouse release is detected on a tab. The action will receive aTabDelegate
instance which not only delegates the current tabbed pane and mouse event, but also tells the action which tab was released and whether the released tab is selected.- Parameters:
onRelease
- The action to be performed when a tab is released.- Returns:
- This builder node.
- Throws:
NullPointerException
- if the given action is null.
-
onTabMouseEnter
Adds an action to be performed when a mouse enter is detected on a tab. The action will receive aTabDelegate
instance which not only delegates the current tabbed pane and mouse event, but also tells the action which tab was entered and whether the entered tab is selected.- Parameters:
onEnter
- The action to be performed when a tab is entered.- Returns:
- This builder node.
- Throws:
NullPointerException
- if the given action is null.
-
onTabMouseExit
Adds an action to be performed when a mouse exit is detected on a tab. The action will receive aTabDelegate
instance which not only delegates the current tabbed pane and mouse event, but also tells the action which tab was exited and whether the exited tab is selected.- Parameters:
onExit
- The action to be performed when a tab is exited.- Returns:
- This builder node.
- Throws:
NullPointerException
- if the given action is null.
-
withSelectedIndex
Sets the selected tab based on the given index.- Parameters:
index
- The index of the tab to select.- Returns:
- This builder node.
-
withSelectedIndex
Dynamically sets the selected tab based on the given index property. So when the index property changes, the selected tab will change accordingly.- Parameters:
index
- The index property of the tab to select.- Returns:
- This builder node.
-
withSelectedIndex
Binds the given index property to the selection index of the tabbed pane, which means that when the index property changes, the selected tab will change accordingly and when the user selects a different tab, the index property will be updated accordingly.- Parameters:
index
- The index property of the tab to select.- Returns:
- This builder node.
-
withTabPlacementAt
Defines the tab placement side based on the givenUI.Side
enum, which maps directly to theJTabbedPane.setTabPlacement(int)
method.- Parameters:
side
- The position to use for the tabs.- Returns:
- This builder node.
-
withTabPlacementAt
Binds the supplied property to the tab placement of the tabbed pane. This means that when the property changes, the tab placement will change accordingly. TheUI.Side
enum maps directly to theJTabbedPane.setTabPlacement(int)
method.- Parameters:
side
- The position property to use for the tabs.- Returns:
- This builder node.
-
withOverflowPolicy
Defines the overflow policy based on the givenUI.OverflowPolicy
enum, which maps directly to theJTabbedPane.setTabLayoutPolicy(int)
method. The overflow policy must either beUI.OverflowPolicy.SCROLL
orUILayoutConstants.WRAP(int)
. TheUI.OverflowPolicy.SCROLL
policy will make the tabs scrollable when there are too many tabs to fit in the tabbed pane. TheUILayoutConstants.WRAP(int)
policy will make the tabs wrap to the next line when there are too many tabs to fit in the tabbed pane.- Parameters:
policy
- The overflow policy to use for the tabs.- Returns:
- This builder node.
-
withOverflowPolicy
Binds the supplied enum property to the overflow policy of the tabbed pane. When the item of the property changes, the overflow policy will change accordingly. TheUI.OverflowPolicy
enum maps directly to theJTabbedPane.setTabLayoutPolicy(int)
method.- Parameters:
policy
- The overflow policy property to use for the tabs.- Returns:
- This builder node.
-
add
Adds a tab to the tabbed pane based on the givenTab
configuration. The tab will be added to the end of the tab list.- Parameters:
tab
- The tab to add to the tabbed pane.- Returns:
- This builder node.
- Throws:
NullPointerException
- if the given tab is null.
-
addAll
Dynamically generates tabs for items in aVals
list and automatically updates them when the items change. The items are typically view model instances, but can be any type.The provided
TabSupplier
lambda is invoked with each item from the list, returning aTab
to be added to theJTabbedPane
wrapped by this builder.Note: Binding tabs to a
Vals
list assumes no other tabs are present.Usage:
UI.panel() .add( UI.tabbedPane().addAll(tabs, model -> switch(model.type()) { case LOGIN -> UI.tab("Login").add(..); case ABOUT -> UI.tab("About").add(..); case SETTINGS -> UI.tab("Settings").add(..); } ) )
- Type Parameters:
M
- The type of items in theVals
list.- Parameters:
tabModels
- A list of items, typically view model instances.tabSupplier
- A lambda to generate aTab
for each item.- Returns:
- This instance, allowing for builder-style method chaining.
-
addAll
public <M> UIForTabbedPane<P> addAll(sprouts.Val<sprouts.Tuple<M>> tabModels, TabSupplier<M> tabSupplier) Dynamically generates tabs for items in aTuple
Val
and automatically updates them when the items change. The tuple items are typically view model instances, but can be any type.The provided
TabSupplier
lambda is invoked with each item from the tuple, returning aTab
to be added to theJTabbedPane
wrapped by this builder.Note: Binding tabs to a
Tuple
Val
assumes no other tabs are present.Usage:
UI.panel() .add( UI.tabbedPane().addAll(tabs, model -> switch(model.type()) { case LOGIN -> UI.tab("Login").add(..); case ABOUT -> UI.tab("About").add(..); case SETTINGS -> UI.tab("Settings").add(..); } ) )
- Type Parameters:
M
- The type of items in the form of aTuple
wrapped by aVal
.- Parameters:
tabModels
- A list of items, typically view model instances.tabSupplier
- A lambda to generate aTab
for each item.- Returns:
- This instance, allowing for builder-style method chaining.
-
onChange
Adds anAction
to the underlyingJTabbedPane
through anChangeListener
, which will be called when the state of the tabbed pane changes. For more information seeJTabbedPane.addChangeListener(javax.swing.event.ChangeListener)
.- Parameters:
onChange
- TheAction
that will be called through the underlying change event.- Returns:
- This very instance, which enables builder-style method chaining.
-