JComponent () { LabeledComponent<EditorTextField> labeledComponent = new LabeledComponent<>(); labeledComponent.setText("Hierarchy root class"); final JavaCodeFragmentFactory factory = JavaCodeFragmentFactory.getInstance(project); final PsiTypeCodeFragment codeFragment = factory.createTypeCodeFragment("", null, true, JavaCodeFragmentFactory.ALLOW_VOID); final Document document = PsiDocumentManager.getInstance(project).getDocument(codeFragment); final EditorTextField editorTextField = new EditorTextField(document, project, JavaFileType.INSTANCE); labeledComponent.setComponent(editorTextField); editorTextField.addDocumentListener(new DocumentListener() { @Override public void documentChanged(@NotNull final com.intellij.openapi.editor.event.DocumentEvent e) { parentClassRef.set(null); try { final PsiType psiType = codeFragment.getType(); final PsiClass psiClass = psiType instanceof PsiClassType ? ((PsiClassType)psiType).resolve() : null; parentClassRef.set(psiClass); } catch (PsiTypeCodeFragment.IncorrectTypeException e1) { // ok } } }); return labeledComponent; }