void () { myNameLabel.setLabelFor(myNameField); myPanel.registerKeyboardAction(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(myNameField, true)); } }, KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.ALT_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW); myNameField.addDataChangedListener(() -> updateOkStatus()); }