JComponent () { mySandboxHome.setHistorySize(5); JPanel wholePanel = new JPanel(new GridBagLayout()); wholePanel.add(mySandboxHomeLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.NONE, JBInsets.emptyInsets(), 0, 0)); wholePanel.add(GuiUtils.constructFieldWithBrowseButton(mySandboxHome, e -> { FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor(); descriptor.setTitle(DevKitBundle.message("sandbox.home")); descriptor.setDescription(DevKitBundle.message("sandbox.purpose")); VirtualFile file = FileChooser.chooseFile(descriptor, mySandboxHome, null, null); if (file != null) { mySandboxHome.setText(FileUtil.toSystemDependentName(file.getPath())); } myModified = true; }), new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, JBUI.insets(0, 30, 0, 0), 0, 0)); wholePanel.add(myInternalJreLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0, 1, GridBagConstraints.WEST, GridBagConstraints.NONE, JBInsets.emptyInsets(), 0, 0)); wholePanel.add(myInternalJres, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 1, 1, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, JBUI.insets(0, 30, 0, 0), 0, 0)); myInternalJres.setRenderer(SimpleListCellRenderer.create("", Sdk::getName)); myInternalJres.addItemListener(e -> { if (myFreeze) return; final Sdk javaJdk = (Sdk)e.getItem(); for (OrderRootType type : OrderRootType.getAllTypes()) { if (!((SdkType) javaJdk.getSdkType()).isRootTypeApplicable(type)) { continue; } final VirtualFile[] internalRoots = javaJdk.getRootProvider().getFiles(type); final VirtualFile[] configuredRoots = mySdkModificator.getRoots(type); for (VirtualFile file : internalRoots) { if (e.getStateChange() == ItemEvent.DESELECTED) { mySdkModificator.removeRoot(file, type); } else { if (ArrayUtil.find(configuredRoots, file) == -1) { mySdkModificator.addRoot(file, type); } } } } }); mySandboxHome.addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(@NotNull DocumentEvent e) { myModified = true; } }); mySandboxHome.addActionListener(e -> myModified = true); mySandboxHome.setText(""); myModified = true; return wholePanel; }