public class XdevKeyAction extends Object
Usage:
Component target = ...; KeyStroke shortcut = ...; XdevKeyAction keyAction = new XdevKeyAction(); keyAction.setTarget(target); keyAction.setShortcut(shortcut); keyAction.addActionListener(...);or just
new XdevKeyAction(cpn,shortcut).addActionListener(...);
Modifier and Type | Class and Description |
---|---|
static class |
XdevKeyAction.Condition
Decides when the key action takes place.
|
Constructor and Description |
---|
XdevKeyAction()
Creates a new empty key action.
|
XdevKeyAction(JComponent target,
KeyStroke shortcut)
Creates a new focus helper with a
shortcut for the component
target . |
Modifier and Type | Method and Description |
---|---|
void |
addActionListener(ActionListener l)
Adds an
ActionListener to the key action. |
protected void |
fireActionPerformed(ActionEvent e) |
ActionListener[] |
getActionListeners()
Returns an array of all the
ActionListener s added to this
key action with addActionListener(ActionListener) |
XdevKeyAction.Condition |
getCondition() |
KeyStroke |
getShortcut()
Return the shortcut associated with this key action.
|
JComponent |
getTarget()
Returns the target of this key action.
|
void |
removeActionListener(ActionListener l)
Removes an
ActionListener from the key action. |
void |
setCondition(XdevKeyAction.Condition condition)
Sets the new condition when the action should take place.
|
void |
setShortcut(KeyStroke shortcut)
Sets the shortcut for this key action.
|
void |
setTarget(JComponent target)
Sets the target component for this key action.
|
public XdevKeyAction()
public XdevKeyAction(JComponent target, KeyStroke shortcut)
shortcut
for the component
target
.target
- the component to focusshortcut
- the keystroke to trigger the actionpublic void setCondition(XdevKeyAction.Condition condition)
condition
- the new conditionXdevKeyAction.Condition
public XdevKeyAction.Condition getCondition()
XdevKeyAction.Condition
public void setTarget(JComponent target)
target
- the component to register the shortcut atpublic JComponent getTarget()
public void setShortcut(KeyStroke shortcut)
shortcut
- the KeyStroke
which triggers this actionpublic KeyStroke getShortcut()
public void addActionListener(ActionListener l)
ActionListener
to the key action.l
- the ActionListener
to be addedpublic void removeActionListener(ActionListener l)
ActionListener
from the key action.l
- the ActionListener
to be removedpublic ActionListener[] getActionListeners()
ActionListener
s added to this
key action with addActionListener(ActionListener)
ActionListener
s added or an empty array
if no listeners have been addedprotected void fireActionPerformed(ActionEvent e)
Copyright © 2003–2021 XDEV Software. All rights reserved.