-
- All Superinterfaces:
Action
,ActionListener
,EventListener
- All Known Subinterfaces:
Controls
,ToggleControl
public interface Control extends Action
A beefed up Action.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
Control.ActionCommand
A command interface, allowing Controls based onActionEvent
s.static interface
Control.Builder
A builder for Controlstatic interface
Control.Command
A command interface, allowing Controls based on method references
-
Field Summary
Fields Modifier and Type Field Description static String
BACKGROUND
The key used for storing the background color.static String
FONT
The key used for storing the Font.static String
FOREGROUND
The key used for storing the foreground color.-
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static Control
actionControl(Control.ActionCommand actionCommand)
Creates a control based on aControl.ActionCommand
static Control.Builder
actionControlBuilder(Control.ActionCommand actionCommand)
Creates a new Builder.static Control.Builder
builder(Control.Command command)
Creates a new Builder.static Control
control(Control.Command command)
Creates a control based on aControl.Command
JButton
createButton()
Creates a button based on this ControlJMenuItem
createMenuItem()
Creates a menu item based on this ControlStateObserver
enabledObserver()
static Control
eventControl(Event<ActionEvent> event)
Creates a Control which triggers the given event on action performedstatic Control.Builder
eventControlBuilder(Event<ActionEvent> event)
Creates a Builder for a control which triggers the given event on action performedColor
getBackground()
String
getCaption()
String
getDescription()
Font
getFont()
Color
getForeground()
KeyStroke
getKeyStroke()
Icon
getLargeIcon()
int
getMnemonic()
Icon
getSmallIcon()
Control
setBackground(Color background)
Control
setCaption(String caption)
Control
setDescription(String description)
void
setEnabled(boolean enabled)
Unsupported, the enabled state of Controls is based on theirenabledState
Control
setFont(Font font)
Control
setForeground(Color foreground)
Control
setKeyStroke(KeyStroke keyStroke)
Control
setLargeIcon(Icon largeIcon)
Control
setMnemonic(int mnemonic)
Control
setSmallIcon(Icon smallIcon)
-
Methods inherited from interface javax.swing.Action
accept, addPropertyChangeListener, getValue, isEnabled, putValue, removePropertyChangeListener
-
Methods inherited from interface java.awt.event.ActionListener
actionPerformed
-
-
-
-
Field Detail
-
FONT
static final String FONT
The key used for storing the Font.- See Also:
- Constant Field Values
-
BACKGROUND
static final String BACKGROUND
The key used for storing the background color.- See Also:
- Constant Field Values
-
FOREGROUND
static final String FOREGROUND
The key used for storing the foreground color.- See Also:
- Constant Field Values
-
-
Method Detail
-
setDescription
Control setDescription(String description)
- Parameters:
description
- the description string- Returns:
- this control instance
-
getDescription
String getDescription()
- Returns:
- the description
-
getCaption
String getCaption()
- Returns:
- the caption
-
setCaption
Control setCaption(String caption)
- Parameters:
caption
- the caption for this Control instance- Returns:
- this Control instance
-
enabledObserver
StateObserver enabledObserver()
- Returns:
- the state which controls whether this Control instance is enabled
-
setMnemonic
Control setMnemonic(int mnemonic)
- Parameters:
mnemonic
- the mnemonic to associate with this Control instance- Returns:
- this Control instance
-
getMnemonic
int getMnemonic()
- Returns:
- the mnemonic, 0 if none is specified
-
setKeyStroke
Control setKeyStroke(KeyStroke keyStroke)
- Parameters:
keyStroke
- the KeyStroke to associate with this Control- Returns:
- this Control instance
-
getKeyStroke
KeyStroke getKeyStroke()
- Returns:
- the KeyStroke associated with this Control, if any
-
setSmallIcon
Control setSmallIcon(Icon smallIcon)
- Parameters:
smallIcon
- the small icon to associate with this Control- Returns:
- this Control instance
-
getSmallIcon
Icon getSmallIcon()
- Returns:
- the icon
-
setLargeIcon
Control setLargeIcon(Icon largeIcon)
- Parameters:
largeIcon
- the large icon to associate with this Control- Returns:
- this Control instance
-
getLargeIcon
Icon getLargeIcon()
- Returns:
- the icon
-
setBackground
Control setBackground(Color background)
- Parameters:
background
- the background color- Returns:
- this Control instance
-
getBackground
Color getBackground()
- Returns:
- the background color
-
setForeground
Control setForeground(Color foreground)
- Parameters:
foreground
- the foreground color- Returns:
- this Control instance
-
getForeground
Color getForeground()
- Returns:
- the foreground color
-
getFont
Font getFont()
- Returns:
- the font
-
createButton
JButton createButton()
Creates a button based on this Control- Returns:
- a button based on this Control
-
createMenuItem
JMenuItem createMenuItem()
Creates a menu item based on this Control- Returns:
- a menu item based on this Control
-
setEnabled
void setEnabled(boolean enabled)
Unsupported, the enabled state of Controls is based on theirenabledState
- Specified by:
setEnabled
in interfaceAction
- Parameters:
enabled
- the enabled status- Throws:
UnsupportedOperationException
- always- See Also:
Control.Builder.enabledState(StateObserver)
-
control
static Control control(Control.Command command)
Creates a control based on aControl.Command
- Parameters:
command
- theControl.Command
on which to base the control- Returns:
- a Control for calling the given
Control.Command
-
actionControl
static Control actionControl(Control.ActionCommand actionCommand)
Creates a control based on aControl.ActionCommand
- Parameters:
actionCommand
- theControl.ActionCommand
on which to base the control- Returns:
- a Control for calling the given
Control.Command
-
eventControl
static Control eventControl(Event<ActionEvent> event)
Creates a Control which triggers the given event on action performed- Parameters:
event
- the event- Returns:
- a control which triggers the given event
-
builder
static Control.Builder builder(Control.Command command)
Creates a new Builder.- Parameters:
command
- the command to base the control on- Returns:
- a new Control.Builder
-
actionControlBuilder
static Control.Builder actionControlBuilder(Control.ActionCommand actionCommand)
Creates a new Builder.- Parameters:
actionCommand
- the action command to base the control on- Returns:
- a new Control.Builder
-
eventControlBuilder
static Control.Builder eventControlBuilder(Event<ActionEvent> event)
Creates a Builder for a control which triggers the given event on action performed- Parameters:
event
- the event- Returns:
- a new Control.Builder
-
-