void (final List<? extends T> items, @NlsContexts.DialogTitle String title, boolean sort) { setTitle(title); myChooser = new ElementsChooser<>(canElementsBeMarked()) { @Override protected String getItemText(final @NotNull T item) { return ChooseElementsDialog.this.getItemText(item); } }; myChooser.setColorUnmarkedElements(false); List<? extends T> elements = new ArrayList<T>(items); if (sort) { elements.sort((Comparator<T>)(o1, o2) -> getItemText(o1).compareToIgnoreCase(getItemText(o2))); } setElements(elements, ContainerUtil.getFirstItems(elements, 1)); myChooser.getComponent().registerKeyboardAction(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doOKAction(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), JComponent.WHEN_FOCUSED); new DoubleClickListener() { @Override protected boolean onDoubleClick(@NotNull MouseEvent e) { doOKAction(); return true; } }.installOn(myChooser.getComponent()); init(); }