Here you can find the source of containerContainsFocus(Container cont)
public static boolean containerContainsFocus(Container cont)
//package com.java2s; //License from project: Open Source License import java.awt.Component; import java.awt.Container; import java.awt.KeyboardFocusManager; import javax.swing.SwingUtilities; public class Main { public static boolean containerContainsFocus(Container cont) /* */{/*w w w .j av a 2 s . co m*/ /* 2298 */Component focusOwner = KeyboardFocusManager .getCurrentKeyboardFocusManager().getFocusOwner(); /* */ /* 2300 */Component permFocusOwner = KeyboardFocusManager .getCurrentKeyboardFocusManager().getPermanentFocusOwner(); /* */ /* 2303 */boolean focusOwned = (focusOwner != null) && (SwingUtilities.isDescendingFrom(focusOwner, cont)); /* 2304 */if (!focusOwned) { /* 2305 */focusOwned = (permFocusOwner != null) && (SwingUtilities.isDescendingFrom(permFocusOwner, cont)); /* */} /* */ /* 2308 */return focusOwned; /* */} }