removeActionListener(oldAction);
oldAction.removePropertyChangeListener(getPropertyChangeHandler());
final Object o = oldAction.getValue(ActionDowngrade.ACCELERATOR_KEY);
if (o instanceof KeyStroke) {
final KeyStroke k = (KeyStroke) o;
unregisterKeyboardAction(k);
}
}
this.action = newAction;
if (this.action != null) {
addActionListener(newAction);
newAction.addPropertyChangeListener(getPropertyChangeHandler());
setText((String) (newAction.getValue(Action.NAME)));
setToolTipText((String) (newAction.getValue(Action.SHORT_DESCRIPTION)));
setIcon((Icon) newAction.getValue(Action.SMALL_ICON));
setEnabled(this.action.isEnabled());
Object o = newAction.getValue(ActionDowngrade.MNEMONIC_KEY);
if (o != null) {
if (o instanceof Character) {
final Character c = (Character) o;
setMnemonic(c.charValue());
}
else if (o instanceof Integer) {
final Integer c = (Integer) o;
setMnemonic(c.intValue());
}
}
o = newAction.getValue(ActionDowngrade.ACCELERATOR_KEY);
if (o instanceof KeyStroke) {
final KeyStroke k = (KeyStroke) o;
registerKeyboardAction(newAction, k, WHEN_IN_FOCUSED_WINDOW);
}
}
}