@Override public void setEnabled(boolean enabled) { if (action != null && enabled != action.isEnabled()) { throw new IllegalArgumentException("Button and action enabled" + " states are not consistent."); } super.setEnabled(enabled); }
/** * "Presses" the button. Performs any action associated with the button. */ public void press() { buttonPressListeners.buttonPressed(this); if (action != null) { action.perform(this); } }
public Action(boolean enabled) { setEnabled(enabled); }
@Override public boolean keyPressed(int keyCode, Keyboard.KeyLocation keyLocation) { /* Use keyPressed rather than keyReleased other this sequence: * Press Ctrl, Press C, Release Ctrl, Release C * will not trigger the Ctrl-C action. */ boolean consumed = super.keyPressed(keyCode, keyLocation); // Perform any action defined for this keystroke // in the active window's action dictionary Keyboard.KeyStroke keyStroke = new Keyboard.KeyStroke(keyCode, Keyboard.getModifiers()); Action action = actionMap.get(keyStroke); if (action != null && action.isEnabled()) { action.perform(this); } return consumed; }
/** * Sets this button's action. * * @param action * The action to be triggered when this button is pressed, or <tt>null</tt> * for no action. */ public void setAction(Action action) { Action previousAction = this.action; if (previousAction != action) { if (previousAction != null) { previousAction.getActionListeners().remove(actionListener); } this.action = action; if (action != null) { action.getActionListeners().add(actionListener); setEnabled(action.isEnabled()); } buttonListeners.actionChanged(this, previousAction); } }
public void setAction(String actionID) { if (actionID == null) { throw new IllegalArgumentException("actionID is null"); } Action action = Action.getNamedActions().get(actionID); if (action == null) { throw new IllegalArgumentException("An action with ID " + actionID + " does not exist."); } setAction(action); } }
@Override public boolean keyPressed(int keyCode, Keyboard.KeyLocation keyLocation) { /* Use keyPressed rather than keyReleased other this sequence: * Press Ctrl, Press C, Release Ctrl, Release C * will not trigger the Ctrl-C action. */ boolean consumed = super.keyPressed(keyCode, keyLocation); // Perform any action defined for this keystroke // in the active window's action dictionary Keyboard.KeyStroke keyStroke = new Keyboard.KeyStroke(keyCode, Keyboard.getModifiers()); Action action = actionMap.get(keyStroke); if (action != null && action.isEnabled()) { action.perform(this); } return consumed; }
/** * Sets this button's action. * * @param action * The action to be triggered when this button is pressed, or <tt>null</tt> * for no action. */ public void setAction(Action action) { Action previousAction = this.action; if (previousAction != action) { if (previousAction != null) { previousAction.getActionListeners().remove(actionListener); } this.action = action; if (action != null) { action.getActionListeners().add(actionListener); setEnabled(action.isEnabled()); } buttonListeners.actionChanged(this, previousAction); } }
public void setAction(String actionID) { if (actionID == null) { throw new IllegalArgumentException("actionID is null"); } Action actionLocal = Action.getNamedActions().get(actionID); if (actionLocal == null) { throw new IllegalArgumentException("An action with ID " + actionID + " does not exist."); } setAction(actionLocal); } }
@Override public void enabledChanged(Action action) { setEnabled(action.isEnabled()); } };
/** * Sets this button's action. * * @param actionID * The ID of the action to be triggered when this button is pressed. * * @throws IllegalArgumentException * If an action with the given ID does not exist. */ public void setAction(String actionID) { if (actionID == null) { throw new IllegalArgumentException("actionID is null"); } Action action = Action.getNamedActions().get(actionID); if (action == null) { throw new IllegalArgumentException("An action with ID " + actionID + " does not exist."); } setAction(action); }
/** * "Presses" the button. Performs any action associated with the button. */ public void press() { buttonPressListeners.buttonPressed(this); if (action != null) { action.perform(this); } }
public Action(boolean enabled) { setEnabled(enabled); }
@Override public void setEnabled(boolean enabled) { if (action != null && enabled != action.isEnabled()) { throw new IllegalArgumentException("Button and action enabled" + " states are not consistent."); } super.setEnabled(enabled); }
/** * Sets this button's action. * * @param actionID * The ID of the action to be triggered when this button is pressed. * * @throws IllegalArgumentException * If an action with the given ID does not exist. */ public void setAction(String actionID) { if (actionID == null) { throw new IllegalArgumentException("actionID is null"); } Action actionLocal = Action.getNamedActions().get(actionID); if (actionLocal == null) { throw new IllegalArgumentException("An action with ID " + actionID + " does not exist."); } setAction(actionLocal); }
@Override public void enabledChanged(Action actionArgument) { setEnabled(actionArgument.isEnabled()); } };