TextFieldWithAutoCompletion<String> (String text, final List<String> variants) { final StringsCompletionProvider provider = new StringsCompletionProvider(variants, null) { @Nullable @Override public String getPrefix(@NotNull String text, int offset) { final int i = text.lastIndexOf('{', offset - 1); if (i < 0) { return ""; } return text.substring(i, offset); } }; return new TextFieldWithAutoCompletion<>(myProject, provider, true, text); } @Override public void setAnchor(@Nullable JComponent anchor) { super.setAnchor(anchor); List<JBLabel> labels = UIUtil.findComponentsOfType(myCustomPanel, JBLabel.class); for (JBLabel label : labels) { label.setAnchor(anchor); } } }