Here you can find the source of isParentWindowFocused(Component component)
Parameter | Description |
---|---|
component | the Component to check the parent Window 's focus for. |
public static boolean isParentWindowFocused(Component component)
//package com.java2s; //License from project: Open Source License import java.awt.*; import javax.swing.SwingUtilities; public class Main { /**/*from w ww. j ava 2 s . c om*/ * {@code true} if the given {@link Component}'s has a parent {@link Window} * (i.e. it's not null) and that {@link Window} is currently active * (focused). * * @param component * the {@code Component} to check the parent {@code Window}'s * focus for. * @return {@code true} if the given {@code Component}'s parent * {@code Window} is currently active. */ public static boolean isParentWindowFocused(Component component) { final Window window = SwingUtilities.getWindowAncestor(component); return window != null && window.isFocused(); } }