summaryrefslogtreecommitdiff
path: root/base/src/main/java/bjc
diff options
context:
space:
mode:
authorBen Culkin <scorpress@gmail.com>2020-11-07 11:57:24 -0500
committerBen Culkin <scorpress@gmail.com>2020-11-07 11:57:24 -0500
commitafa28a5f997f1353988bfba2c223eadea9737340 (patch)
tree4ff3e2b128b9fa5d8a92ee856587fb4b2427a59a /base/src/main/java/bjc
parentd0bca88c56f76ee15a91fe111b1c040d42f174df (diff)
Return the bound action for SimpleKeyedButton
In case anyone wants it, SimpleKeyedButton now returns the created action when it is set
Diffstat (limited to 'base/src/main/java/bjc')
-rw-r--r--base/src/main/java/bjc/utils/gui/SimpleKeyedButton.java10
1 files changed, 8 insertions, 2 deletions
diff --git a/base/src/main/java/bjc/utils/gui/SimpleKeyedButton.java b/base/src/main/java/bjc/utils/gui/SimpleKeyedButton.java
index 0c40fbe..976b259 100644
--- a/base/src/main/java/bjc/utils/gui/SimpleKeyedButton.java
+++ b/base/src/main/java/bjc/utils/gui/SimpleKeyedButton.java
@@ -59,8 +59,9 @@ public class SimpleKeyedButton extends JButton {
* @param aevListener
* The listener that handles the implementation of the
* action.
+ * @return The action that was bound to the button.
*/
- public void setGlobalDefaultKeystroke(String eventName, String keystroke,
+ public Action setGlobalDefaultKeystroke(String eventName, String keystroke,
Consumer<ActionEvent> aevListener) {
Action act = new KeyedButtonAction(eventName, aevListener);
KeyStroke stroke = KeyStroke.getKeyStroke(keystroke);
@@ -69,6 +70,8 @@ public class SimpleKeyedButton extends JButton {
this.getInputMap(WHEN_IN_FOCUSED_WINDOW).put(stroke, eventName);
this.getActionMap().put(eventName, act);
this.setText(label);
+
+ return act;
}
/**
@@ -82,8 +85,9 @@ public class SimpleKeyedButton extends JButton {
* @param aevListener
* The listener that handles the implementation of the
* action.
+ * @return The action that was bound to the button.
*/
- public void addGlobalKeystroke(String eventName, String keystroke,
+ public Action addGlobalKeystroke(String eventName, String keystroke,
Consumer<ActionEvent> aevListener) {
Action act = new KeyedButtonAction(eventName, aevListener);
KeyStroke stroke = KeyStroke.getKeyStroke(keystroke);
@@ -91,5 +95,7 @@ public class SimpleKeyedButton extends JButton {
this.getInputMap(WHEN_IN_FOCUSED_WINDOW).put(stroke, eventName);
this.getActionMap().put(eventName, act);
this.setText(label);
+
+ return act;
}
}