Component () { if (!myOpened) { final DialogWrapper wrapper = getDialogWrapper(); if (wrapper != null) { JComponent toFocus = wrapper.getPreferredFocusedComponent(); if (toFocus != null) { return toFocus; } } } return super.getMostRecentFocusOwner(); }