LabeledComponent<TextFieldWithBrowseButton> () { myLocationField = new TextFieldWithBrowseButton(); final String projectLocation = myProjectDirectory.get().toString(); myLocationField.setText(projectLocation); final int index = projectLocation.lastIndexOf(File.separator); if (index > 0) { JTextField textField = myLocationField.getTextField(); textField.select(index + 1, projectLocation.length()); textField.putClientProperty(DialogWrapperPeer.HAVE_INITIAL_SELECTION, true); } final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor(); myLocationField.addBrowseFolderListener(IdeBundle.message("directory.project.location.title"), IdeBundle.message("directory.project.location.description"), null, descriptor); return LabeledComponent.create(myLocationField, BundleBase.replaceMnemonicAmpersand(IdeBundle.message("directory.project.location.label")), BorderLayout.WEST); }