public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
String propertyName = propertyChangeEvent.getPropertyName();
JMenuItem menuItem = FixedJMenuItem.this;
- if (propertyChangeEvent.getPropertyName().equals(Action.NAME)) {
- String text = (String) propertyChangeEvent.getNewValue();
- menuItem.setText(text);
- menuItem.repaint();
- } else if (propertyName.equals("enabled")) {
+ if ("enabled".equals(propertyName)) {
Boolean enabledState = (Boolean) propertyChangeEvent.getNewValue();
menuItem.setEnabled(enabledState.booleanValue());
menuItem.repaint();
- } else if (propertyChangeEvent.getPropertyName().equals(Action.SMALL_ICON)) {
- Icon icon = (Icon) propertyChangeEvent.getNewValue();
- menuItem.setIcon(icon);
- menuItem.invalidate();
+ } else if (Action.NAME.equals(propertyName)) {
+ String text = (String) propertyChangeEvent.getNewValue();
+ menuItem.setText(text);
+ menuItem.repaint();
+ } else if (Action.SHORT_DESCRIPTION.equals(propertyName)) {
+ String shortDescription = (String) propertyChangeEvent.getNewValue();
+ menuItem.setToolTipText(shortDescription);
menuItem.repaint();
- } else if (propertyChangeEvent.getPropertyName().equals(Action.MNEMONIC_KEY)) {
+ } else if (Action.MNEMONIC_KEY.equals(propertyName)) {
Integer mn = (Integer) propertyChangeEvent.getNewValue();
menuItem.setMnemonic(mn.intValue());
menuItem.invalidate();
menuItem.repaint();
- } else if (propertyChangeEvent.getPropertyName().equals(Action.ACCELERATOR_KEY)) {
+ } 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();
}
}
};