JComponent () { myNameField = new NameSuggestionsField(myProject); myNameChangedListener = () -> updateOkStatus(); myNameField.addDataChangedListener(myNameChangedListener); JPanel panel = new JPanel(new GridBagLayout()); GridBagConstraints gbConstraints = new GridBagConstraints(); gbConstraints.insets = JBUI.insets(4); gbConstraints.anchor = GridBagConstraints.WEST; gbConstraints.fill = GridBagConstraints.BOTH; gbConstraints.gridwidth = 1; gbConstraints.weightx = 0; gbConstraints.weighty = 0; gbConstraints.gridx = 0; gbConstraints.gridy = 0; JLabel type = new JLabel(JavaRefactoringBundle.message("variable.of.type")); panel.add(type, gbConstraints); gbConstraints.gridx++; myTypeSelector = myTypeSelectorManager.getTypeSelector(); panel.add(myTypeSelector.getComponent(), gbConstraints); gbConstraints.gridwidth = 1; gbConstraints.weightx = 0; gbConstraints.weighty = 0; gbConstraints.gridx = 0; gbConstraints.gridy = 1; JLabel namePrompt = new JLabel(RefactoringBundle.message("name.prompt")); namePrompt.setLabelFor(myNameField.getComponent()); panel.add(namePrompt, gbConstraints); gbConstraints.gridwidth = 1; gbConstraints.weightx = 1; gbConstraints.gridx = 1; gbConstraints.gridy = 1; panel.add(myNameField.getComponent(), gbConstraints); myNameSuggestionsManager = new NameSuggestionsManager(myTypeSelector, myNameField, new NameSuggestionsGenerator() { @Override public SuggestedNameInfo getSuggestedNameInfo(PsiType type) { return CommonJavaRefactoringUtil.getSuggestedName(type, myExpression); } }); myNameSuggestionsManager.setLabelsFor(type, namePrompt); return panel; }