import java.beans.PropertyChangeListener;
import javax.swing.Action;
-import javax.swing.Icon;
import javax.swing.JMenuItem;
import javax.swing.KeyStroke;
/**
- * MenuItem which fixes the bug that when the {@link Action#ACCELERATOR_KEY}
- * value of the action the JMenuItem is based upen is changed this change is not
- * picked up (see <a
+ * MenuItem which fixes the bug that when the {@link Action#ACCELERATOR_KEY} and
+ * {@link Action#SHORT_DESCRIPTION} values of the action the JMenuItem is based
+ * upen is changed this change is not picked up (see <a
* href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4304129">bug
* #4304129</a>).
*
* {@inheritDoc}
*/
@Override
- protected PropertyChangeListener createActionPropertyChangeListener(Action a) {
+ protected PropertyChangeListener createActionPropertyChangeListener(Action action) {
+ final PropertyChangeListener originalPropertyChangeListener = super.createActionPropertyChangeListener(action);
return new PropertyChangeListener() {
/**
* {@inheritDoc}
*/
public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
+ originalPropertyChangeListener.propertyChange(propertyChangeEvent);
String propertyName = propertyChangeEvent.getPropertyName();
JMenuItem menuItem = FixedJMenuItem.this;
- if ("enabled".equals(propertyName)) {
- Boolean enabledState = (Boolean) propertyChangeEvent.getNewValue();
- menuItem.setEnabled(enabledState.booleanValue());
- menuItem.repaint();
- } else if (Action.NAME.equals(propertyName)) {
- String text = (String) propertyChangeEvent.getNewValue();
- menuItem.setText(text);
- menuItem.repaint();
- } else if (Action.SHORT_DESCRIPTION.equals(propertyName)) {
+ if (Action.SHORT_DESCRIPTION.equals(propertyName)) {
String shortDescription = (String) propertyChangeEvent.getNewValue();
menuItem.setToolTipText(shortDescription);
menuItem.repaint();
- } else if (Action.MNEMONIC_KEY.equals(propertyName)) {
- Integer mn = (Integer) propertyChangeEvent.getNewValue();
- menuItem.setMnemonic(mn.intValue());
- menuItem.invalidate();
- menuItem.repaint();
} else if (Action.ACCELERATOR_KEY.equals(propertyName)) {
KeyStroke keyStroke = (KeyStroke) propertyChangeEvent.getNewValue();
menuItem.setAccelerator(keyStroke);
menuItem.invalidate();
menuItem.repaint();
- } else if (Action.SMALL_ICON.equals(propertyName)) {
- Icon icon = (Icon) propertyChangeEvent.getNewValue();
- menuItem.setIcon(icon);
- menuItem.invalidate();
- menuItem.repaint();
}
}
};