void (JComponent component) { @NlsSafe String actionName = "FCB_END_CTRL"; Action action = new AbstractAction(actionName) { private static final long serialVersionUID = 1945871436968682881L; @Override public void actionPerformed(ActionEvent e) { // if focus is on the popup: select the very last item on the // popup, changing probably from the history list to the choices // list; if the item is already on the very last element, or // the focus is on the text field, move the caret to the end if (!popup.isPopupFocused() || !popup.selectLast(true)) { 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, InputEvent.CTRL_MASK), actionName); }