JComponent () { JPanel panel = new JPanel(new VerticalFlowLayout()); JLabel nameLabel = new JLabel(); panel.add(nameLabel); myNameField = new JTextField(); nameLabel.setLabelFor(myNameField); myNameField.getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(@NotNull DocumentEvent e) { validateOKButton(); } }); panel.add(myNameField); nameLabel.setText(getNameLabel()); myTargetDirLabel = new JLabel(); panel.add(myTargetDirLabel); myTargetDirectoryField = new TextFieldWithBrowseButton(); myTargetDirectoryField.setText(myCurrentDirectory.getVirtualFile().getPresentableUrl()); myTargetDirectoryField.addBrowseFolderListener(RefactoringBundle.message("select.target.directory"), RefactoringBundle.message("select.target.directory.description"), null, FileChooserDescriptorFactory.createSingleFolderDescriptor()); myTargetDirLabel.setText(RefactoringBundle.message("extract.to.directory")); panel.add(myTargetDirectoryField); myTargetDirectoryField.getTextField().getDocument().addDocumentListener(new DocumentAdapter() { @Override public void textChanged(@NotNull DocumentEvent event) { validateOKButton(); } }); validateOKButton(); return panel; }