boolean (Component @NotNull [] components) { Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); if (owner == null) return false; Window wnd = ComponentUtil.getWindow(owner); for (Component each : components) { if (each != null && SwingUtilities.isDescendingFrom(owner, each)) { Window eachWindow = ComponentUtil.getWindow(each); if (eachWindow == wnd) { return true; } } } return false; }