JComponent () { myCanBeFinalCb = new NonFocusableCheckBox(GroovyRefactoringBundle.message("declare.final.checkbox")); myCanBeFinalCb.setSelected(false); myCanBeFinalCb.setMnemonic(KeyEvent.VK_F); final GrFinalListener finalListener = new GrFinalListener(myEditor); myCanBeFinalCb.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { WriteCommandAction.writeCommandAction(myProject).withName(getCommandName()).withGroupId(getCommandName()).run(() -> { PsiDocumentManager.getInstance(myProject).commitDocument(myEditor.getDocument()); final GrVariable variable = getVariable(); if (variable != null) { finalListener.perform(myCanBeFinalCb.isSelected(), variable); } }); } }); final JPanel panel = new JPanel(new GridBagLayout()); panel.setBorder(null); if (myCanBeFinalCb != null) { panel.add(myCanBeFinalCb, new GridBagConstraints(0, 1, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); } panel.add(Box.createVerticalBox(), new GridBagConstraints(0, 2, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); return panel; }