Changeset 17667 in josm for trunk/src/org


Ignore:
Timestamp:
2021-03-25T22:58:47+01:00 (4 years ago)
Author:
simon04
Message:

fix #15397 - Toolbar: make ToggleAction buttons reflect toggle state

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/PreferenceToggleAction.java

    r17021 r17667  
    1818 * register another {@link PreferenceChangedListener} for the given preference key.
    1919 */
    20 public class PreferenceToggleAction extends JosmAction implements PreferenceChangedListener {
     20public class PreferenceToggleAction extends ToggleAction implements PreferenceChangedListener {
    2121
    2222    private final JCheckBoxMenuItem checkbox;
  • trunk/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java

    r17307 r17667  
    3232
    3333import javax.swing.AbstractAction;
     34import javax.swing.AbstractButton;
    3435import javax.swing.Action;
    3536import javax.swing.DefaultListCellRenderer;
     
    6869import org.openstreetmap.josm.actions.ParameterizedAction;
    6970import org.openstreetmap.josm.actions.ParameterizedActionDecorator;
     71import org.openstreetmap.josm.actions.ToggleAction;
    7072import org.openstreetmap.josm.data.imagery.ImageryInfo;
    7173import org.openstreetmap.josm.data.imagery.ImageryLayerInfo;
     74import org.openstreetmap.josm.gui.IconToggleButton;
    7275import org.openstreetmap.josm.gui.MainApplication;
    7376import org.openstreetmap.josm.gui.MapFrame;
     
    11701173                control.addSeparator();
    11711174            } else {
    1172                 final JButton b = addButtonAndShortcut(action);
     1175                final AbstractButton b = addButtonAndShortcut(action);
    11731176                buttonActions.put(b, action);
    11741177
     
    12301233    }
    12311234
    1232     private JButton addButtonAndShortcut(ActionDefinition action) {
     1235    private AbstractButton addButtonAndShortcut(ActionDefinition action) {
    12331236        Action act = action.getParametrizedAction();
    1234         JButton b = control.add(act);
     1237        final AbstractButton b;
     1238        if (act instanceof ToggleAction) {
     1239            b = new IconToggleButton(act);
     1240            control.add(b);
     1241        } else {
     1242            b = control.add(act);
     1243        }
    12351244
    12361245        Shortcut sc = null;
Note: See TracChangeset for help on using the changeset viewer.