Here you can find the source of isParentWindowFocused(Component component)
public static boolean isParentWindowFocused(Component component)
//package com.java2s; /******************************************************************************* * Copyright (c) 2011 Zeljko Zirikovic./* ww w . ja v a 2s.com*/ * All rights reserved. This program and the accompanying materials * are made available under the terms of the GPL which * accompanies this distribution, and is available at * http://www.gnu.org/licenses/gpl.html ******************************************************************************/ import java.awt.Component; import java.awt.Window; import javax.swing.SwingUtilities; public class Main { public static boolean isParentWindowFocused(Component component) { Window window = SwingUtilities.getWindowAncestor(component); return window != null && window.isFocused(); } }