From: David ‘Bombe’ Roden Date: Sun, 6 Apr 2008 14:44:46 +0000 (+0000) Subject: better fix X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=b2dfa2aa2e736a822695e63c1712771c85d5d834;p=jSite2.git better fix git-svn-id: http://trooper/svn/projects/jSite/trunk@621 c3eda9e8-030b-0410-8277-bc7414b0a119 --- diff --git a/src/net/pterodactylus/jsite/gui/FixedJMenuItem.java b/src/net/pterodactylus/jsite/gui/FixedJMenuItem.java index 0aad34a..f38097b 100644 --- a/src/net/pterodactylus/jsite/gui/FixedJMenuItem.java +++ b/src/net/pterodactylus/jsite/gui/FixedJMenuItem.java @@ -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 bug * #4304129). * @@ -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(); } } };