JComponent () { final JPanel panel = new JPanel(new GridBagLayout()); mySourcePathsChooser = new ElementsChooser<>(true) { @Override public String getItemText(@NotNull JavaModuleSourceRoot sourceRoot) { String packagePrefix = sourceRoot.getPackagePrefix(); return sourceRoot.getDirectory().getAbsolutePath() + (packagePrefix.isEmpty() ? "" : " (" + packagePrefix + ")") + " [" + sourceRoot.getRootTypeName() + "]"; } }; final String text = JavaUiBundle.message("label.java.source.files.have.been.found"); final JLabel label = new JLabel(text); label.setUI(new MultiLineLabelUI()); panel.add(label, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, JBUI.insets(8, 10, 0, 10), 0, 0)); panel.add(mySourcePathsChooser, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, JBInsets.create(8, 10), 0, 0)); final JButton markAllButton = new JButton(JavaUiBundle.message("button.mark.all")); panel.add(markAllButton, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, JBUI.insets(0, 10, 8, 2), 0, 0)); final JButton unmarkAllButton = new JButton(JavaUiBundle.message("button.unmark.all")); panel.add(unmarkAllButton, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, JBUI.insets(0, 0, 8, 10), 0, 0)); markAllButton.addActionListener(__ -> mySourcePathsChooser.setAllElementsMarked(true)); unmarkAllButton.addActionListener(__ -> mySourcePathsChooser.setAllElementsMarked(false)); return panel; }