JComponent () { JPanel panel = new JPanel(new GridBagLayout()); GridBagConstraints gbConstraints = new GridBagConstraints(); gbConstraints.insets = JBUI.insets(4, 4, 4, 0); gbConstraints.anchor = GridBagConstraints.EAST; gbConstraints.fill = GridBagConstraints.BOTH; gbConstraints.gridwidth = 1; gbConstraints.weightx = 0; gbConstraints.weighty = 1; gbConstraints.gridx = 0; gbConstraints.gridy = 0; final JLabel type = new JLabel(getTypeLabel()); panel.add(type, gbConstraints); gbConstraints.gridx++; gbConstraints.insets = JBUI.insets(4, 0, 4, 4); gbConstraints.weightx = 0; myTypeSelector = myTypeSelectorManager.getTypeSelector(); panel.add(myTypeSelector.getComponent(), gbConstraints); gbConstraints.insets = JBUI.insets(4, 4, 4, 0); gbConstraints.gridwidth = 1; gbConstraints.weightx = 0; gbConstraints.weighty = 1; gbConstraints.gridx = 0; gbConstraints.gridy = 1; final JLabel namePrompt = new JLabel(RefactoringBundle.message("name.prompt")); panel.add(namePrompt, gbConstraints); gbConstraints.insets = JBUI.insets(4, 0, 4, 4); gbConstraints.gridwidth = 1; gbConstraints.weightx = 1; gbConstraints.gridx = 1; gbConstraints.gridy = 1; myNameField = new NameSuggestionsField(myProject); panel.add(myNameField.getComponent(), gbConstraints); myNameField.addDataChangedListener(() -> updateButtons()); namePrompt.setLabelFor(myNameField.getFocusableComponent()); // We delay initialization of name field till dialog is shown, so that it will be executed in a different command and won't // be tied to any document changes performed in current command (and won't prevent undo for them later) UiNotifyConnector.Once.installOn(panel, new Activatable() { @Override public void showNotify() { myNameSuggestionsManager = new NameSuggestionsManager(myTypeSelector, myNameField, JavaNameSuggestionUtil.createFieldNameGenerator(myWillBeDeclaredStatic, myLocalVariable, myInitializerExpression, myIsInvokedOnDeclaration, myEnteredName, myParentClass, myProject)); myNameSuggestionsManager.setLabelsFor(type, namePrompt); Editor editor = myNameField.getEditor(); if (editor != null) { editor.getSelectionModel().setSelection(0, editor.getDocument().getTextLength()); } } }); return panel; }