void () { DefaultComboBoxModel model = new DefaultComboBoxModel(); FileTemplate[] allTemplates = FileTemplateManager.getInstance(myProject).getAllTemplates(); PsiDirectory[] dirs = {myDirectory}; for (FileTemplate template : allTemplates) { if (FileTemplateUtil.canCreateFromTemplate(dirs, template)) { model.addElement(template); } } if(myCbxTemplates == null){ myCbxTemplates = new ComboBox(model); ComboboxSpeedSearch search = new ComboboxSpeedSearch(myCbxTemplates, null) { @Override protected String getElementText(Object element) { return element instanceof FileTemplate ? ((FileTemplate)element).getName() : null; } }; search.setupListeners(); myCbxTemplates.setRenderer(SimpleListCellRenderer.create((label, fileTemplate, index) -> { if (fileTemplate != null) { label.setIcon(FileTemplateUtil.getIcon(fileTemplate)); label.setText(fileTemplate.getName()); } })); } else{ Object selected = myCbxTemplates.getSelectedItem(); myCbxTemplates.setModel(model); if(selected != null){ myCbxTemplates.setSelectedItem(selected); } } }