java.lang.Object
swingtree.AbstractDelegate<I>
swingtree.SplitItemDelegate<I>
- Type Parameters:
I
- TheJMenuItem
subtype for which this context was created.
Instances of this are delegated to the individual
JSplitButton
items
and their ActionEvent
s exposed to you inside your Action
handlers,
like for example one you would supply to SplitItem.onSelection(Action)
.
This class exists to give said actions all the necessary context
they need to perform their tasks.-
Method Summary
Modifier and TypeMethodDescriptionappendToButtonText
(String postfix) Appends the suppliedString
to the text displayed on theJSplitButton
.Use this to conveniently make theJSplitButton
display the text of the currently selectedJMenuItem
(button item).Allows you to retrieve the text currently displayed on theJSplitButton
.final I
Exposes theJMenuItem
which is currently selected by the user and displayed as the button item of theJSplitButton
.getEvent()
Exposes the underlyingActionEvent
that is being handled by this delegate.This method provides a convenient way to access all the children of the parent component of the split item this delegate is for.Exposes the "siblings" of the delegated component, which refers to all children of its parent component, except for itself.Returns the underlyingJSplitButton
instance or throws an exception if the current thread is not the Swing thread.prependToButtonText
(String prefix) A convenience method which takes the suppliedString
and prepends it to the text displayed on theJSplitButton
.selectItem
(int i) Selects the targeted split item (JMenuItem
).Selects only the currentJMenuItem
by passingtrue
to theAbstractButton.setSelected(boolean)
method.selectOnlyItem
(int i) Selects the targeted split item (JMenuItem
) and unselects all other items.setButtonText
(String text) Takes the suppliedString
and passes it to theAbstractButton.setText(String)
while running on the UI thread.unselectItem
(int i) Unselects the targeted split item (JMenuItem
).Methods inherited from class swingtree.AbstractDelegate
_component, _isUndefinedColor, _isUndefinedFont, _siblingsSource, animateFor, animateFor, animateFor, animateFor, animateStyleFor, animateStyleFor, find, find, find, findAll, findAllByGroup, findAllByGroup, findAllByGroup, findAllByGroup, get, getBackground, getBorder, getBounds, getCursor, getFont, getForeground, getHeight, getLocation, getMaxSize, getMinSize, getParent, getPrefSize, getScale, getSize, getTooltip, getWidth, getX, getY, isEnabled, isOpaque, isVisible, paint, paint, paint, paint, parentDelegate, scale, scale, scale, scale, setBackground, setBackgroundColor, setBackgroundColor, setBackgroundColor, setBackgroundColor, setBorder, setBounds, setBounds, setBounds, setCursor, setCursor, setEnabled, setFont, setForeground, setForegroundColor, setForegroundColor, setForegroundColor, setForegroundColor, setHeight, setMaxHeight, setMaxSize, setMaxSize, setMaxSize, setMaxWidth, setMinHeight, setMinSize, setMinSize, setMinSize, setMinWidth, setOpaque, setPrefHeight, setPrefSize, setPrefSize, setPrefSize, setPrefWidth, setSize, setSize, setSize, setTooltip, setVisible, setWidth, shapeOf, style
-
Method Details
-
getEvent
Exposes the underlyingActionEvent
that is being handled by this delegate. It is a semantic event which indicates that a component-defined action occurred. This high-level event is generated by the split button when the component-specific action occurs (such as being pressed). The event is originally passed to everyActionListener
object that registered to receive such events using the component'saddActionListener
method.- Returns:
- The
ActionEvent
which caused this action to be executed.
-
getSplitButton
Returns the underlyingJSplitButton
instance or throws an exception if the current thread is not the Swing thread.- Returns:
- The
JSplitButton
to which thisSplitItem
(and itsJMenuItem
) belongs.
-
getCurrentItem
Exposes theJMenuItem
which is currently selected by the user and displayed as the button item of theJSplitButton
. This is the item which caused theActionEvent
to be fired.- Returns:
- The
JMenuItem
which caused this action to be executed.
-
getSiblinghood
This method provides a convenient way to access all the children of the parent component of the split item this delegate is for.- Returns:
- A list of all the
JMenuItem
which constitute the options exposed by theJSplitButton
.
-
getSiblings
Exposes the "siblings" of the delegated component, which refers to all children of its parent component, except for itself. This is contrary to thegetSiblinghood()
method which returns all children of the parent component including the current component.- Returns:
- A list of all the
JMenuItem
which constitute the options exposed by theJSplitButton
except the currentJMenuItem
exposed bygetCurrentItem()
.
-
selectCurrentItem
- Returns:
- This
SplitItemDelegate
instance to allow for method chaining.
-
selectOnlyCurrentItem
Selects only the currentJMenuItem
by passingtrue
to theAbstractButton.setSelected(boolean)
method. All otherJMenuItem
s will be unselected.- Returns:
- This
SplitItemDelegate
instance to allow for method chaining.
-
unselectCurrentItem
- Returns:
- This
SplitItemDelegate
instance to allow for method chaining.
-
unselectAllItems
- Returns:
- This
SplitItemDelegate
instance to allow for method chaining.
-
selectAllItems
- Returns:
- This
SplitItemDelegate
instance to allow for method chaining.
-
displayCurrentItemText
Use this to conveniently make theJSplitButton
display the text of the currently selectedJMenuItem
(button item).- Returns:
- This
SplitItemDelegate
instance to allow for method chaining.
-
setButtonText
Takes the suppliedString
and passes it to theAbstractButton.setText(String)
while running on the UI thread.- Parameters:
text
- The text which should be displayed on theJSplitButton
.- Returns:
- This
SplitItemDelegate
instance to allow for method chaining.
-
getButtonText
Allows you to retrieve the text currently displayed on theJSplitButton
.- Returns:
- The text displayed on the
JSplitButton
.
-
appendToButtonText
Appends the suppliedString
to the text displayed on theJSplitButton
.- Parameters:
postfix
- The text which should be appended to the text displayed on theJSplitButton
.- Returns:
- This
SplitItemDelegate
instance to allow for method chaining.
-
prependToButtonText
A convenience method which takes the suppliedString
and prepends it to the text displayed on theJSplitButton
. This method is equivalent to callingsetButtonText(String)
with the concatenation of the suppliedString
and the current text displayed on theJSplitButton
.- Parameters:
prefix
- The text which should be prepended to the text displayed on theJSplitButton
.- Returns:
- This
SplitItemDelegate
instance to allow for method chaining.
-
selectItem
Selects the targeted split item (JMenuItem
).- Parameters:
i
- The item index of theJMenuItem
which should be selected.- Returns:
- This
SplitItemDelegate
instance to allow for method chaining.
-
selectOnlyItem
Selects the targeted split item (JMenuItem
) and unselects all other items.- Parameters:
i
- The item index of theJMenuItem
which should be selected exclusively.- Returns:
- This
SplitItemDelegate
instance to allow for method chaining.
-
unselectItem
Unselects the targeted split item (JMenuItem
).- Parameters:
i
- The item index of theJMenuItem
which should be unselected.- Returns:
- This
SplitItemDelegate
instance to allow for method chaining.
-