JPanel (ItemListener itemListener) { GridBagConstraints gbConstraints = new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, JBInsets.emptyInsets(), 0, 0); JPanel panel = new JPanel(new GridBagLayout()); myCbFinal = new StateRestoringCheckBox(); myCbFinal.setFocusable(false); myCbFinal.setText(JavaRefactoringBundle.message("declare.final")); myCbFinal.addItemListener(itemListener); gbConstraints.gridy++; panel.add(myCbFinal, gbConstraints); appendOccurrences(itemListener, gbConstraints, panel); if (myLocalVariable != null) { gbConstraints.gridy++; if (myCbReplaceAll != null) { gbConstraints.insets = JBUI.insetsLeft(8); } myCbDeleteVariable = new StateRestoringCheckBox(); myCbDeleteVariable.setText(JavaRefactoringBundle.message("delete.variable.declaration")); panel.add(myCbDeleteVariable, gbConstraints); if (myIsInvokedOnDeclaration) { myCbDeleteVariable.setEnabled(false); myCbDeleteVariable.setSelected(true); } else if (myCbReplaceAll != null) { updateCbDeleteVariable(); myCbReplaceAll.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { updateCbDeleteVariable(); } } ); } } return panel; }