better fix
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 6 Apr 2008 14:44:46 +0000 (14:44 +0000)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 6 Apr 2008 14:44:46 +0000 (14:44 +0000)
git-svn-id: http://trooper/svn/projects/jSite/trunk@621 c3eda9e8-030b-0410-8277-bc7414b0a119

src/net/pterodactylus/jsite/gui/FixedJMenuItem.java

index 0aad34a..f38097b 100644 (file)
@@ -23,14 +23,13 @@ import java.beans.PropertyChangeEvent;
 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>).
  * 
@@ -53,42 +52,26 @@ public class FixedJMenuItem extends JMenuItem {
         * {@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();
                                }
                        }
                };