Optional<Component> (Component source) { if (source instanceof JComboBox && !((JComboBox<?>)source).isEditable() || source instanceof JCheckBox || source instanceof JRadioButton || source instanceof TagButton) { return Optional.of(source); } return UIUtil.uiTraverser(source) .filter(c -> ( (c instanceof JTextComponent && c.isFocusable()) || (c instanceof EditorTextComponent && c instanceof FocusListener)) // EditorTextField ) .toList().stream().findFirst(); }