java.lang.Object
swingtree.AbstractDelegate<I>
swingtree.SplitItemDelegate<I>
- Type Parameters:
I- TheJMenuItemsubtype for which this context was created.
Instances of this are delegated to the individual
JSplitButton items
and their ActionEvents 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 suppliedStringto the text displayed on theJSplitButton.Use this to conveniently make theJSplitButtondisplay the text of the currently selectedJMenuItem(button item).Allows you to retrieve the text currently displayed on theJSplitButton.final IExposes theJMenuItemwhich is currently selected by the user and displayed as the button item of theJSplitButton.getEvent()Exposes the underlyingActionEventthat 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 underlyingJSplitButtoninstance or throws an exception if the current thread is not the Swing thread.prependToButtonText(String prefix) A convenience method which takes the suppliedStringand prepends it to the text displayed on theJSplitButton.selectItem(int i) Selects the targeted split item (JMenuItem).Selects only the currentJMenuItemby passingtrueto theAbstractButton.setSelected(boolean)method.selectOnlyItem(int i) Selects the targeted split item (JMenuItem) and unselects all other items.setButtonText(String text) Takes the suppliedStringand 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 underlyingActionEventthat 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 everyActionListenerobject that registered to receive such events using the component'saddActionListenermethod.- Returns:
- The
ActionEventwhich caused this action to be executed.
-
getSplitButton
Returns the underlyingJSplitButtoninstance or throws an exception if the current thread is not the Swing thread.- Returns:
- The
JSplitButtonto which thisSplitItem(and itsJMenuItem) belongs.
-
getCurrentItem
Exposes theJMenuItemwhich is currently selected by the user and displayed as the button item of theJSplitButton. This is the item which caused theActionEventto be fired.- Returns:
- The
JMenuItemwhich 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
JMenuItemwhich 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
JMenuItemwhich constitute the options exposed by theJSplitButtonexcept the currentJMenuItemexposed bygetCurrentItem().
-
selectCurrentItem
- Returns:
- This
SplitItemDelegateinstance to allow for method chaining.
-
selectOnlyCurrentItem
Selects only the currentJMenuItemby passingtrueto theAbstractButton.setSelected(boolean)method. All otherJMenuItems will be unselected.- Returns:
- This
SplitItemDelegateinstance to allow for method chaining.
-
unselectCurrentItem
- Returns:
- This
SplitItemDelegateinstance to allow for method chaining.
-
unselectAllItems
- Returns:
- This
SplitItemDelegateinstance to allow for method chaining.
-
selectAllItems
- Returns:
- This
SplitItemDelegateinstance to allow for method chaining.
-
displayCurrentItemText
Use this to conveniently make theJSplitButtondisplay the text of the currently selectedJMenuItem(button item).- Returns:
- This
SplitItemDelegateinstance to allow for method chaining.
-
setButtonText
Takes the suppliedStringand passes it to theAbstractButton.setText(String)while running on the UI thread.- Parameters:
text- The text which should be displayed on theJSplitButton.- Returns:
- This
SplitItemDelegateinstance 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 suppliedStringto the text displayed on theJSplitButton.- Parameters:
postfix- The text which should be appended to the text displayed on theJSplitButton.- Returns:
- This
SplitItemDelegateinstance to allow for method chaining.
-
prependToButtonText
A convenience method which takes the suppliedStringand prepends it to the text displayed on theJSplitButton. This method is equivalent to callingsetButtonText(String)with the concatenation of the suppliedStringand the current text displayed on theJSplitButton.- Parameters:
prefix- The text which should be prepended to the text displayed on theJSplitButton.- Returns:
- This
SplitItemDelegateinstance to allow for method chaining.
-
selectItem
Selects the targeted split item (JMenuItem).- Parameters:
i- The item index of theJMenuItemwhich should be selected.- Returns:
- This
SplitItemDelegateinstance to allow for method chaining.
-
selectOnlyItem
Selects the targeted split item (JMenuItem) and unselects all other items.- Parameters:
i- The item index of theJMenuItemwhich should be selected exclusively.- Returns:
- This
SplitItemDelegateinstance to allow for method chaining.
-
unselectItem
Unselects the targeted split item (JMenuItem).- Parameters:
i- The item index of theJMenuItemwhich should be unselected.- Returns:
- This
SplitItemDelegateinstance to allow for method chaining.
-