void (JComponent component) { @NlsSafe String actionName = "FCB_HOME"; Action action = new AbstractAction(actionName) { private static final long serialVersionUID = -1583258893221830664L; @Override public void actionPerformed(ActionEvent e) { if (!popup.isPopupFocused() || !popup.selectFirst(false)) { if (e.getSource() instanceof JTextField textField) { textField.setCaretPosition(0); } } } }; component.getActionMap().put(actionName, action); component.getInputMap(JComponent.WHEN_FOCUSED) .put(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0), actionName); }