Changeset 35163 in osm


Ignore:
Timestamp:
2019-09-29T23:23:10+02:00 (5 years ago)
Author:
donvip
Message:

use DisableShortcutsOnFocusGainedTextField

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/geochat/src/geochat/JPanelTextField.java

    r33545 r35163  
    11// License: WTFPL. For details, see LICENSE file.
    22package geochat;
    3 
    4 import static org.openstreetmap.josm.tools.I18n.tr;
    53
    64import java.awt.KeyboardFocusManager;
     
    108
    119import javax.swing.JComponent;
    12 import javax.swing.JMenuItem;
    13 import javax.swing.JPopupMenu;
    14 import javax.swing.JTextField;
    1510import javax.swing.KeyStroke;
    16 import javax.swing.text.DefaultEditorKit;
    1711
    1812import org.openstreetmap.josm.gui.MainApplication;
    19 import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher;
     13import org.openstreetmap.josm.gui.widgets.DisableShortcutsOnFocusGainedTextField;
    2014
    2115/**
     
    2519 * @author zverik
    2620 */
    27 public class JPanelTextField extends JTextField {
     21public class JPanelTextField extends DisableShortcutsOnFocusGainedTextField {
    2822
    2923    public JPanelTextField() {
    3024        setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, new HashSet<KeyStroke>());
    31         PopupMenuLauncher launcher = new PopupMenuLauncher(createEditMenu());
    32         addMouseListener(launcher);
    3325        standardKeys = getInputMap(JComponent.WHEN_FOCUSED).allKeys();
    34     }
    35 
    36     private JPopupMenu createEditMenu() {
    37         JPopupMenu menu = new JPopupMenu();
    38         menu.add(createMenuItem(DefaultEditorKit.cutAction, tr("Cut")));
    39         menu.add(createMenuItem(DefaultEditorKit.copyAction, tr("Copy")));
    40         menu.add(createMenuItem(DefaultEditorKit.pasteAction, tr("Paste")));
    41         menu.add(createMenuItem(DefaultEditorKit.selectAllAction, tr("Select All")));
    42         return menu;
    43     }
    44 
    45     private JMenuItem createMenuItem(String action, String label) {
    46         JMenuItem item = new JMenuItem(getActionMap().get(action));
    47         item.setText(label);
    48         return item;
    4926    }
    5027
Note: See TracChangeset for help on using the changeset viewer.