diff options
| author | Ben Culkin <scorpress@gmail.com> | 2020-04-13 18:40:41 -0400 |
|---|---|---|
| committer | Ben Culkin <scorpress@gmail.com> | 2020-04-13 18:40:41 -0400 |
| commit | d4ca769e542b2489b1e23cfcbdc3a0b7275b87cd (patch) | |
| tree | 1653a7399f97fb0c63ce62e3f60fd830d5c37f70 /base/src/main/java/bjc/utils/gui/SimpleKeyedButton.java | |
| parent | 2ac2e31a56ae59ee582e43a90c3495f86dd9ee7a (diff) | |
Cleanup pass
Cleanup pass to uniformize things
Diffstat (limited to 'base/src/main/java/bjc/utils/gui/SimpleKeyedButton.java')
| -rw-r--r-- | base/src/main/java/bjc/utils/gui/SimpleKeyedButton.java | 54 |
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); |
