998.3.24
by Kenneth Yrke Jørgensen
Moved location of swing helper classes to .net.tapaal.swinghelpers |
1 |
package net.tapaal.swinghelpers; |
2 |
||
3 |
import javax.swing.JComponent; |
|
4 |
import javax.swing.SwingUtilities; |
|
5 |
import javax.swing.event.AncestorEvent; |
|
6 |
import javax.swing.event.AncestorListener; |
|
7 |
||
8 |
public class RequestFocusListener implements AncestorListener |
|
9 |
{
|
|
10 |
public RequestFocusListener() |
|
11 |
{
|
|
12 |
}
|
|
13 |
||
14 |
||
15 |
public void ancestorAdded(final AncestorEvent arg0) |
|
16 |
{
|
|
17 |
//JComponent component = arg0.getComponent();
|
|
18 |
//component.requestFocusInWindow();
|
|
19 |
||
20 |
final AncestorListener al= this; |
|
21 |
SwingUtilities.invokeLater(() -> { |
|
22 |
JComponent component = arg0.getComponent(); |
|
23 |
component.requestFocusInWindow(); |
|
24 |
component.removeAncestorListener( al ); |
|
25 |
});
|
|
26 |
}
|
|
27 |
||
28 |
public void ancestorMoved(AncestorEvent arg0) { |
|
29 |
// TODO Auto-generated method stub
|
|
30 |
||
31 |
}
|
|
32 |
||
33 |
||
34 |
public void ancestorRemoved(AncestorEvent arg0) { |
|
35 |
// TODO Auto-generated method stub
|
|
36 |
||
37 |
}
|
|
38 |
}
|