Changeset 5471 in josm
- Timestamp:
- 2012-08-22T01:48:59+02:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/SideButton.java
r5463 r5471 27 27 public class SideButton extends JButton implements Destroyable { 28 28 private final static int iconHeight = 20; 29 30 private PropertyChangeListener propertyChangeListener; 29 31 30 32 public SideButton(Action action) … … 52 54 } 53 55 54 void fixIcon(Action action) { 56 private void fixIcon(Action action) { 55 57 // need to listen for changes, so that putValue() that are called after the 56 58 // SideButton is constructed get the proper icon size 57 if(action != null) { 58 action.addPropertyChangeListener(new PropertyChangeListener() { 59 if (action != null) { 60 action.addPropertyChangeListener(propertyChangeListener = new PropertyChangeListener() { 59 61 @Override 60 62 public void propertyChange(PropertyChangeEvent evt) { 61 if(evt.getPropertyName() == javax.swing.Action.SMALL_ICON) { 63 if (evt.getPropertyName() == javax.swing.Action.SMALL_ICON) { 62 64 fixIcon(null); 63 65 } … … 66 68 } 67 69 Icon i = getIcon(); 68 if(i != null && i instanceof ImageIcon && i.getIconHeight() != iconHeight) { 70 if (i != null && i instanceof ImageIcon && i.getIconHeight() != iconHeight) { 69 71 setIcon(getScaledImage(((ImageIcon) i).getImage())); 70 72 } … … 144 146 ((Destroyable) action).destroy(); 145 147 } 146 setAction(null); 148 if (action != null) { 149 if (propertyChangeListener != null) { 150 action.removePropertyChangeListener(propertyChangeListener); 151 } 152 setAction(null); 153 } 147 154 } 148 155 }
Note:
See TracChangeset
for help on using the changeset viewer.