Changeset 10179 in josm for trunk/src/org/openstreetmap/josm/gui/SideButton.java
- Timestamp:
- 2016-05-11T02:44:10+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/SideButton.java
r9705 r10179 22 22 23 23 /** 24 * Button that is usually used in toggle dialogs 24 * Button that is usually used in toggle dialogs. 25 * @since 744 25 26 */ 26 27 public class SideButton extends JButton implements Destroyable { … … 29 30 private transient PropertyChangeListener propertyChangeListener; 30 31 32 /** 33 * Constructs a new {@code SideButton}. 34 * @param action action used to specify the new button 35 */ 31 36 public SideButton(Action action) { 32 37 super(action); … … 35 40 } 36 41 42 /** 43 * Constructs a new {@code SideButton}. 44 * @param action action used to specify the new button 45 * @param usename use action name 46 */ 37 47 public SideButton(Action action, boolean usename) { 38 48 super(action); … … 44 54 } 45 55 56 /** 57 * Constructs a new {@code SideButton}. 58 * @param action action used to specify the new button 59 * @param imagename image name in "dialogs" directory 60 */ 46 61 public SideButton(Action action, String imagename) { 47 62 super(action); 48 setIcon( makeIcon(imagename));63 setIcon(getScaledImage(ImageProvider.get("dialogs", imagename).getImage())); 49 64 doStyle(); 50 65 } … … 54 69 // SideButton is constructed get the proper icon size 55 70 if (action != null) { 56 action.addPropertyChangeListener(propertyChangeListener = new PropertyChangeListener() {71 propertyChangeListener = new PropertyChangeListener() { 57 72 @Override 58 73 public void propertyChange(PropertyChangeEvent evt) { … … 61 76 } 62 77 } 63 }); 78 }; 79 action.addPropertyChangeListener(propertyChangeListener); 64 80 } 65 81 Icon i = getIcon(); … … 77 93 int newWidth = im.getWidth(null) * iconHeight / im.getHeight(null); 78 94 return new ImageIcon(im.getScaledInstance(newWidth, iconHeight, Image.SCALE_SMOOTH)); 79 }80 81 public static ImageIcon makeIcon(String imagename) {82 Image im = ImageProvider.get("dialogs", imagename).getImage();83 return getScaledImage(im);84 95 } 85 96
Note:
See TracChangeset
for help on using the changeset viewer.