JComponent () { myPackageTextField.getDocument().addDocumentListener(new DocumentListener() { @Override public void documentChanged(@NotNull DocumentEvent e) { PsiNameHelper nameHelper = PsiNameHelper.getInstance(myProject); String packageName = getPackageName(); getOKAction().setEnabled(nameHelper.isQualifiedName(packageName) || packageName.isEmpty()); } }); new AnAction() { @Override public void actionPerformed(@NotNull AnActionEvent e) { myPackageChooseButton.doClick(); } }.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.SHIFT_DOWN_MASK)), myPackageTextField); return myContentPane; }