From d4ca769e542b2489b1e23cfcbdc3a0b7275b87cd Mon Sep 17 00:00:00 2001 From: Ben Culkin Date: Mon, 13 Apr 2020 18:40:41 -0400 Subject: Cleanup pass Cleanup pass to uniformize things --- .../main/java/bjc/utils/gui/SimpleKeyedButton.java | 54 ++++++++++++++-------- 1 file changed, 34 insertions(+), 20 deletions(-) (limited to 'base/src/main/java/bjc/utils/gui/SimpleKeyedButton.java') 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 aevListener) { + public void setGlobalDefaultKeystroke(String eventName, String keystroke, + Consumer 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 aevListener) { + public void addGlobalKeystroke(String eventName, String keystroke, + Consumer 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); -- cgit v1.2.3