Changeset 35163 in osm
- Timestamp:
- 2019-09-29T23:23:10+02:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/geochat/src/geochat/JPanelTextField.java
r33545 r35163 1 1 // License: WTFPL. For details, see LICENSE file. 2 2 package geochat; 3 4 import static org.openstreetmap.josm.tools.I18n.tr;5 3 6 4 import java.awt.KeyboardFocusManager; … … 10 8 11 9 import javax.swing.JComponent; 12 import javax.swing.JMenuItem;13 import javax.swing.JPopupMenu;14 import javax.swing.JTextField;15 10 import javax.swing.KeyStroke; 16 import javax.swing.text.DefaultEditorKit;17 11 18 12 import org.openstreetmap.josm.gui.MainApplication; 19 import org.openstreetmap.josm.gui.widgets. PopupMenuLauncher;13 import org.openstreetmap.josm.gui.widgets.DisableShortcutsOnFocusGainedTextField; 20 14 21 15 /** … … 25 19 * @author zverik 26 20 */ 27 public class JPanelTextField extends JTextField {21 public class JPanelTextField extends DisableShortcutsOnFocusGainedTextField { 28 22 29 23 public JPanelTextField() { 30 24 setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, new HashSet<KeyStroke>()); 31 PopupMenuLauncher launcher = new PopupMenuLauncher(createEditMenu());32 addMouseListener(launcher);33 25 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;49 26 } 50 27
Note:
See TracChangeset
for help on using the changeset viewer.