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

Last change on this file since 30 was 30, checked in by imi, 18 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
Line 
1package org.openstreetmap.josm.gui;
2
3import java.beans.PropertyChangeEvent;
4import java.beans.PropertyChangeListener;
5
6import javax.swing.Action;
7import javax.swing.JComponent;
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 */
16public class IconToggleButton extends JToggleButton implements PropertyChangeListener {
17
18 /**
19 * Construct the toggle button with the given action.
20 */
21 public IconToggleButton(JComponent acceleratorReceiver, Action action) {
22 super(action);
23 setText(null);
24
25 // Tooltip
26 String toolTipText = "";
27 Object o = action.getValue(Action.SHORT_DESCRIPTION);
28 if (o != null)
29 toolTipText = o.toString();
30 setToolTipText(toolTipText);
31
32 action.addPropertyChangeListener(this);
33 }
34
35 public void propertyChange(PropertyChangeEvent evt) {
36 if (evt.getPropertyName().equals("active"))
37 setSelected((Boolean)evt.getNewValue());
38 }
39}
Note: See TracBrowser for help on using the repository browser.