Adding Actions to Buttons and Menu Items

AbstractButton
+ AbstractButton(Action)
+ setAction(Action)
# configurePropertiesFromAction(Action)
# createPropertyChangeListener(Action)
+ setActionCommand(String)
+ setEnabled(boolean)
+ setIcon(Icon)
+ setText(String)
+ setToolTipText(String)


When you pass an Action to the button's constructor the button configures itself using the Action's properties...

...and adds a property change listener to the Action.

 public class AbstractButton  {

    public AbstractButton(Action action) {
        configurePropertiesFromAction(action);
        createPropertyChangeListener(action);
    }

    protected void configurePropertiesFromAction(Action action) {

        setActionCommand((String) action.getValue(Action.ACTION_COMMAND_KEY));
        setEnabled      (         action.isEnabled());
        setIcon         ((Icon)   action.getValue(Action.SMALL_ICON));
        setText         ((String) action.getValue(Action.NAME));
        setToolTipText  ((String) action.getValue(Action.SHORT_DESCRIPTION));
    }
}