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.
|
---|
2 | package org.openstreetmap.josm.gui.widgets;
|
---|
3 |
|
---|
4 | import java.awt.Component;
|
---|
5 | import java.awt.event.FocusAdapter;
|
---|
6 | import java.awt.event.FocusEvent;
|
---|
7 |
|
---|
8 | import javax.swing.text.JTextComponent;
|
---|
9 |
|
---|
10 | public 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.