Here you can find the source of setFocusOn(Component component)
public static final void setFocusOn(Component component)
//package com.java2s; //License from project: Apache License import java.awt.Component; import javax.swing.SwingUtilities; public class Main { public static final void setFocusOn(Component component) { final Component reference = component; SwingUtilities.invokeLater(new Runnable() { public void run() { reference.requestFocus(); }//ww w. j a v a 2 s. c om }); } }