source: josm/src/org/openstreetmap/josm/gui/IconToggleButton.java@ 30

Last change on this file since 30 was 30, checked in by imi, 19 years ago
  • Removed edit layer, combine action, save gpx (integrated in normal save)
  • Simplified and unified shortkeys
  • many small code simplifications
  • added undo
  • broken checkin!
File size: 972 bytes
RevLine 
[1]1package org.openstreetmap.josm.gui;
2
[7]3import java.beans.PropertyChangeEvent;
4import java.beans.PropertyChangeListener;
5
[1]6import javax.swing.Action;
[4]7import javax.swing.JComponent;
[1]8import javax.swing.JToggleButton;
9
10/**
11 * Just a toggle button, with smaller border and icon only to display in
12 * MapFrame toolbars.
13 *
14 * @author imi
15 */
[7]16public class IconToggleButton extends JToggleButton implements PropertyChangeListener {
[1]17
18 /**
19 * Construct the toggle button with the given action.
20 */
[4]21 public IconToggleButton(JComponent acceleratorReceiver, Action action) {
[1]22 super(action);
23 setText(null);
[7]24
25 // Tooltip
26 String toolTipText = "";
[30]27 Object o = action.getValue(Action.SHORT_DESCRIPTION);
[4]28 if (o != null)
[30]29 toolTipText = o.toString();
[7]30 setToolTipText(toolTipText);
31
32 action.addPropertyChangeListener(this);
[1]33 }
[7]34
35 public void propertyChange(PropertyChangeEvent evt) {
[8]36 if (evt.getPropertyName().equals("active"))
[7]37 setSelected((Boolean)evt.getNewValue());
38 }
[1]39}
Note: See TracBrowser for help on using the repository browser.