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