Component () { Window[] windows = Window.getWindows(); for (Window each : windows) { if (each.isActive()) { return each; } } final IdeFrame frame = IdeFocusManager.findInstance().getLastFocusedFrame(); if (frame != null) return frame.getComponent(); return JOptionPane.getRootFrame(); }