Here you can find the source of clearAWTFocus(Robot robot)
public static void clearAWTFocus(Robot robot) throws InterruptedException, InvocationTargetException, AWTException
//package com.java2s; import java.lang.reflect.InvocationTargetException; import java.awt.AWTException; import java.awt.Robot; public class Main { public static final int ROBOT_DELAY = 100; public static void clearAWTFocus(Robot robot) throws InterruptedException, InvocationTargetException, AWTException {/*w w w . j a va 2s . co m*/ if (null == robot) { robot = new Robot(); robot.setAutoWaitForIdle(true); } javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { System.err.println("******** clearAWTFocus.0"); java.awt.KeyboardFocusManager .getCurrentKeyboardFocusManager() .clearGlobalFocusOwner(); } }); robot.delay(ROBOT_DELAY); System.err.println("******** clearAWTFocus.X"); } }