Changeset 15109 in josm


Ignore:
Timestamp:
2019-05-25T14:01:50+02:00 (5 months ago)
Author:
GerdP
Message:

fix #17754: Search dialog input field doesn't react on changes in radio buttons

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/SearchDialog.java

    r15108 r15109  
    1010import java.awt.GridBagLayout;
    1111import java.awt.event.ActionEvent;
     12import java.awt.event.ItemEvent;
     13import java.awt.event.ItemListener;
    1214import java.awt.event.MouseAdapter;
    1315import java.awt.event.MouseEvent;
     
    116118        regexSearch = new JRadioButton(tr("regular expression"), searchSettings.regexSearch);
    117119        mapCSSSearch = new JRadioButton(tr("MapCSS selector"), searchSettings.mapCSSSearch);
     120
    118121        ButtonGroup bg2 = new ButtonGroup();
    119122        bg2.add(standardSearch);
     
    163166         * the text field is colored red.
    164167         */
    165         document.addDocumentListener(new AbstractTextComponentValidator(editorComponent) {
     168        AbstractTextComponentValidator validator = new AbstractTextComponentValidator(editorComponent) {
    166169
    167170            @Override
     
    188191                }
    189192            }
    190         });
     193        };
     194        document.addDocumentListener(validator);
     195        ItemListener validateActionListener = e -> {
     196            if (e.getStateChange() == ItemEvent.SELECTED) {
     197                validator.validate();
     198            }
     199        };
     200        standardSearch.addItemListener(validateActionListener);
     201        regexSearch.addItemListener(validateActionListener);
     202        mapCSSSearch.addItemListener(validateActionListener);
    191203
    192204        /*
Note: See TracChangeset for help on using the changeset viewer.