~yrke/tapaal/slimImageIcons-2

« back to all changes in this revision

Viewing changes to src/net/tapaal/swinghelpers/RequestFocusListener.java

  • Committer: Jiri Srba
  • Date: 2020-04-28 19:15:28 UTC
  • mfrom: (998.2.376 testbranch)
  • Revision ID: srba@cs.aau.dk-20200428191528-3xxjqa1r4jcob5ur
merged in lp:~yrke/tapaal/testbranch doing majour refactoring of the GUI

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
}