Java Swing Focus clearAWTFocus(Robot robot)

Here you can find the source of clearAWTFocus(Robot robot)

Description

clear AWT Focus

License

Open Source License

Declaration

public static void clearAWTFocus(Robot robot)
            throws InterruptedException, InvocationTargetException,
            AWTException 

Method Source Code

//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");
    }
}

Related

  1. addDefaultFocus(Window window, final JComponent component)
  2. adjustFocus(JComponent c)
  3. centreInFocusedWindow(Window window, int xOffset, int yOffset)
  4. checkComponentsFocusable(final Component _rootComponent)
  5. compositeRequestFocus(Component component)
  6. containerContainsFocus(Container cont)
  7. containerContainsFocus(Container cont)
  8. createWizardFocusAdapter()