Changeset 11300 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2016-11-23T23:39:47+01:00 (7 years ago)
Author:
simon04
Message:

Jump to Position: focus first input, select text in textfield on focus

File:
1 edited

Legend:

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

    r11100 r11300  
    1919import org.openstreetmap.josm.data.Bounds;
    2020import org.openstreetmap.josm.data.coor.LatLon;
     21import org.openstreetmap.josm.gui.ExtendedDialog;
    2122import org.openstreetmap.josm.gui.MapView;
    2223import org.openstreetmap.josm.gui.widgets.JosmTextField;
     24import org.openstreetmap.josm.gui.widgets.SelectAllOnFocusGainedDecorator;
    2325import org.openstreetmap.josm.tools.GBC;
    2426import org.openstreetmap.josm.tools.ImageProvider;
     
    112114        url.getDocument().addDocumentListener(new OsmURLListener());
    113115
     116        SelectAllOnFocusGainedDecorator.decorate(lat);
     117        SelectAllOnFocusGainedDecorator.decorate(lon);
     118        SelectAllOnFocusGainedDecorator.decorate(zm);
     119        SelectAllOnFocusGainedDecorator.decorate(url);
     120
    114121        JPanel p = new JPanel(new GridBagLayout());
    115122        panel.add(p, BorderLayout.NORTH);
     
    127134        p.add(url, GBC.eol().fill(GBC.HORIZONTAL));
    128135
    129         Object[] buttons = {tr("Jump there"), tr("Cancel")};
     136        String[] buttons = {tr("Jump there"), tr("Cancel")};
    130137        LatLon ll = null;
    131138        double zoomLvl = 100;
    132139        while (ll == null) {
    133             int option = JOptionPane.showOptionDialog(
    134                             Main.parent,
    135                             panel,
    136                             tr("Jump to Position"),
    137                             JOptionPane.OK_CANCEL_OPTION,
    138                             JOptionPane.PLAIN_MESSAGE,
    139                             null,
    140                             buttons,
    141                             buttons[0]);
    142 
    143             if (option != JOptionPane.OK_OPTION) return;
     140            final int option = new ExtendedDialog(Main.parent, tr("Jump to Position"), buttons) {{
     141                setContent(panel);
     142                setCancelButton(2);
     143            }}.showDialog().getValue();
     144
     145            if (option != 1) return;
    144146            try {
    145147                zoomLvl = Double.parseDouble(zm.getText());
Note: See TracChangeset for help on using the changeset viewer.