JComponent () { final JPanel panel = new JPanel(new GridBagLayout()); final String text = JavaUiBundle.message("prompt.please.specify.java.sources.directory"); final JLabel label = new JLabel(text); label.setUI(new MultiLineLabelUI()); panel.add(label, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, JBUI.insets(8, 10, 0, 10), 0, 0)); myRbCreateSource = new JRadioButton(JavaUiBundle.message("radio.create.source.directory"), true); panel.add(myRbCreateSource, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, JBUI.insets(8, 10, 0, 10), 0, 0)); myTfSourceDirectoryName = new JTextField(suggestSourceDirectoryName()); final JLabel srcPathLabel = new JLabel(JavaUiBundle.message("prompt.enter.relative.path.to.module.content.root", File.separator)); panel.add(srcPathLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, JBUI.insets(8, 30, 0, 0), 0, 0)); final FileChooserDescriptor chooserDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor(); chooserDescriptor.withTreeRootVisible(true); final FieldPanel fieldPanel = createFieldPanel(myTfSourceDirectoryName, null, new BrowsePathListener(myTfSourceDirectoryName, chooserDescriptor)); panel.add(fieldPanel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, JBUI.insets(8, 30, 0, 10), 0, 0)); myRbNoSource = new JRadioButton(JavaUiBundle.message("radio.do.not.create.source.directory"), true); panel.add(myRbNoSource, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, JBUI.insets(8, 10, 0, 10), 0, 0)); final JLabel fullPathLabel = new JLabel(JavaUiBundle.message("label.source.directory")); panel.add(fullPathLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.SOUTHWEST, GridBagConstraints.NONE, JBUI.insets(8, 10, 0, 10), 0, 0)); myTfFullPath = new JTextField(); myTfFullPath.setEditable(false); myTfFullPath.setOpaque(false); final Insets borderInsets = myTfFullPath.getBorder().getBorderInsets(myTfFullPath); myTfFullPath.setBorder(BorderFactory.createEmptyBorder(borderInsets.top, borderInsets.left, borderInsets.bottom, borderInsets.right)); panel.add(myTfFullPath, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.SOUTHWEST, GridBagConstraints.HORIZONTAL, JBInsets.create(8, 10), 0, 0)); ButtonGroup group = new ButtonGroup(); group.add(myRbCreateSource); group.add(myRbNoSource); myTfSourceDirectoryName.getDocument().addDocumentListener(new DocumentAdapter() { @Override public void textChanged(@NotNull DocumentEvent event) { updateFullPathField(); } }); myRbCreateSource.addItemListener(e -> { final boolean enabled = e.getStateChange() == ItemEvent.SELECTED; srcPathLabel.setEnabled(enabled); fieldPanel.setEnabled(enabled); fullPathLabel.setVisible(enabled); myTfFullPath.setVisible(enabled); if (enabled) { IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(myTfSourceDirectoryName, true)); } }); return panel; }