| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
package org.fest.swing.core; |
| 16 |
|
|
| 17 |
|
import static org.fest.swing.core.FocusOwnerFinder.focusOwner; |
| 18 |
|
|
| 19 |
|
import java.awt.Component; |
| 20 |
|
import java.awt.event.FocusAdapter; |
| 21 |
|
import java.awt.event.FocusEvent; |
| 22 |
|
|
| 23 |
|
|
| 24 |
|
@link |
| 25 |
|
|
| 26 |
|
@author |
| 27 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 5 |
Complexity Density: 0.71 |
|
| 28 |
|
final class FocusMonitor extends FocusAdapter { |
| 29 |
|
|
| 30 |
|
private volatile boolean focused = false; |
| 31 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 32 |
17
|
static FocusMonitor attachTo(Component c) {... |
| 33 |
17
|
FocusMonitor monitor = new FocusMonitor(c); |
| 34 |
17
|
c.addFocusListener(monitor); |
| 35 |
17
|
return monitor; |
| 36 |
|
} |
| 37 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 38 |
17
|
private FocusMonitor(Component c) {... |
| 39 |
17
|
focused = focusOwner() == c; |
| 40 |
|
} |
| 41 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 42 |
13
|
@Override public void focusGained(FocusEvent e) {... |
| 43 |
13
|
focused = true; |
| 44 |
|
} |
| 45 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 46 |
3
|
@Override public void focusLost(FocusEvent e) {... |
| 47 |
3
|
focused = false; |
| 48 |
|
} |
| 49 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 50 |
18
|
boolean hasFocus() { return focused; }... |
| 51 |
|
} |