Here you can find the source of containerContainsFocus(Container cont)
Parameter | Description |
---|---|
cont | the specified container |
public static boolean containerContainsFocus(Container cont)
//package com.java2s; import javax.swing.*; import java.awt.*; public class Main { /**/* ww w. ja va 2s . c o m*/ * containerContainsFocus, does the specified container contain the current focusOwner? * * @param cont the specified container * @return Is the current focusOwner a descendant of the specified container, or the container itself? */ public static boolean containerContainsFocus(Container cont) { Component focusOwner = KeyboardFocusManager .getCurrentKeyboardFocusManager().getFocusOwner(); Component permFocusOwner = KeyboardFocusManager .getCurrentKeyboardFocusManager().getPermanentFocusOwner(); boolean focusOwned; focusOwned = ((focusOwner != null) && SwingUtilities .isDescendingFrom(focusOwner, cont)); if (!focusOwned) { focusOwned = ((permFocusOwner != null) && SwingUtilities .isDescendingFrom(permFocusOwner, cont)); } return focusOwned; } }