source: josm/trunk/src/org/openstreetmap/josm/gui/widgets/SelectAllOnFocusGainedDecorator.java@ 9059

Last change on this file since 9059 was 9059, checked in by Don-vip, 8 years ago

checkstyle

  • Property svn:eol-style set to native
File size: 700 bytes
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.widgets;
3
4import java.awt.Component;
5import java.awt.event.FocusAdapter;
6import java.awt.event.FocusEvent;
7
8import javax.swing.text.JTextComponent;
9
10public class SelectAllOnFocusGainedDecorator extends FocusAdapter {
11
12 public static void decorate(JTextComponent tc) {
13 if (tc == null) return;
14 tc.addFocusListener(new SelectAllOnFocusGainedDecorator());
15 }
16
17 @Override
18 public void focusGained(FocusEvent e) {
19 Component c = e.getComponent();
20 if (c instanceof JTextComponent) {
21 JTextComponent tc = (JTextComponent) c;
22 tc.selectAll();
23 }
24 }
25}
Note: See TracBrowser for help on using the repository browser.