boolean (Component c) { if (c instanceof JComboBox<?> comboBox) { if (!comboBox.isEnabled()) { return false; } if (comboBox.isEditable()) { ComboBoxEditor ed = comboBox.getEditor(); Component editorComponent = ed.getEditorComponent(); Component focused = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); return focused != null && editorComponent != null && SwingUtilities.isDescendingFrom(focused, editorComponent); } else { return comboBox.hasFocus(); } } return false; }