ComboBox<Object> (@NotNull Runnable onShowAllSelected, @NotNull Runnable onSdkSelected) { final ComboBox<Object> result = new ComboBox<>() { @Override public void setSelectedItem(Object item) { if (getShowAll().equals(item)) { ApplicationManager.getApplication().invokeLater(onShowAllSelected); } else if (!PySdkListCellRenderer.SEPARATOR.equals(item)) { super.setSelectedItem(item); } } }; result.addItemListener( e -> { if (e.getStateChange() == ItemEvent.SELECTED) onSdkSelected.run(); } ); ComboboxSpeedSearch.installOn(result); result.setPreferredSize(result.getPreferredSize()); // this line allows making `result` resizable return result; }