summaryrefslogtreecommitdiff
path: root/base/src/main/java/bjc/utils/gui/SimpleKeyedButton.java
diff options
context:
space:
mode:
Diffstat (limited to 'base/src/main/java/bjc/utils/gui/SimpleKeyedButton.java')
-rw-r--r--base/src/main/java/bjc/utils/gui/SimpleKeyedButton.java54
1 files changed, 34 insertions, 20 deletions
diff --git a/base/src/main/java/bjc/utils/gui/SimpleKeyedButton.java b/base/src/main/java/bjc/utils/gui/SimpleKeyedButton.java
index 031cee3..0c40fbe 100644
--- a/base/src/main/java/bjc/utils/gui/SimpleKeyedButton.java
+++ b/base/src/main/java/bjc/utils/gui/SimpleKeyedButton.java
@@ -10,7 +10,7 @@ import javax.swing.KeyStroke;
/**
* Simple {@link JButton} that provides an easy way to add a key-map to it.
- *
+ *
* @author Ben Culkin
*
*/
@@ -32,48 +32,62 @@ public class SimpleKeyedButton extends JButton {
}
private static final long serialVersionUID = -8550504153221678178L;
-
+
private String label;
/**
* Create a new keyed button.
- *
- * @param label The label for the button.
+ *
+ * @param label
+ * The label for the button.
*/
public SimpleKeyedButton(String label) {
super(label);
-
+
this.label = label;
}
-
+
/**
- * Sets the default action for this button, and installs a global (WHEN_IN_FOCUSED_WINDOW) keystroke handler for it.
- *
- * @param eventName An unique internal name for the event.
- * @param keystroke The keystroke for this event, passed to {@link KeyStroke#getKeyStroke(String)}.
- * @param aevListener The listener that handles the implementation of the action.
+ * Sets the default action for this button, and installs a global
+ * (WHEN_IN_FOCUSED_WINDOW) keystroke handler for it.
+ *
+ * @param eventName
+ * An unique internal name for the event.
+ * @param keystroke
+ * The keystroke for this event, passed to
+ * {@link KeyStroke#getKeyStroke(String)}.
+ * @param aevListener
+ * The listener that handles the implementation of the
+ * action.
*/
- public void setGlobalDefaultKeystroke(String eventName, String keystroke, Consumer<ActionEvent> aevListener) {
+ public void setGlobalDefaultKeystroke(String eventName, String keystroke,
+ Consumer<ActionEvent> aevListener) {
Action act = new KeyedButtonAction(eventName, aevListener);
KeyStroke stroke = KeyStroke.getKeyStroke(keystroke);
-
+
this.setAction(act);
this.getInputMap(WHEN_IN_FOCUSED_WINDOW).put(stroke, eventName);
this.getActionMap().put(eventName, act);
this.setText(label);
}
-
+
/**
* Installs a global (WHEN_IN_FOCUSED_WINDOW) keystroke handler for an action.
- *
- * @param eventName An unique internal name for the event.
- * @param keystroke The keystroke for this event, passed to {@link KeyStroke#getKeyStroke(String)}.
- * @param aevListener The listener that handles the implementation of the action.
+ *
+ * @param eventName
+ * An unique internal name for the event.
+ * @param keystroke
+ * The keystroke for this event, passed to
+ * {@link KeyStroke#getKeyStroke(String)}.
+ * @param aevListener
+ * The listener that handles the implementation of the
+ * action.
*/
- public void addGlobalKeystroke(String eventName, String keystroke, Consumer<ActionEvent> aevListener) {
+ public void addGlobalKeystroke(String eventName, String keystroke,
+ Consumer<ActionEvent> aevListener) {
Action act = new KeyedButtonAction(eventName, aevListener);
KeyStroke stroke = KeyStroke.getKeyStroke(keystroke);
-
+
this.getInputMap(WHEN_IN_FOCUSED_WINDOW).put(stroke, eventName);
this.getActionMap().put(eventName, act);
this.setText(label);