JComponent () { JPanel panel = new JPanel(new BorderLayout()); panel.add(createTable(), BorderLayout.CENTER); myCbEncapsulateGet.setText(JavaRefactoringBundle.message("encapsulate.fields.get.access.checkbox")); myCbEncapsulateSet.setText(JavaRefactoringBundle.message("encapsulate.fields.set.access.checkbox")); myCbUseAccessorsWhenAccessible.setText(JavaRefactoringBundle.message("encapsulate.fields.use.accessors.even.when.field.is.accessible.checkbox")); myRbFieldPrivate.setText(JavaRefactoringBundle.message("encapsulate.fields.private.radio")); myRbFieldProtected.setText(JavaRefactoringBundle.message("encapsulate.fields.protected.radio")); myRbFieldPackageLocal.setText(JavaRefactoringBundle.message("encapsulate.fields..package.local.radio")); myRbFieldAsIs.setText(RefactoringBundle.getVisibilityAsIs()); myRbAccessorPublic.setText(RefactoringBundle.getVisibilityPublic()); myRbAccessorProtected.setText(RefactoringBundle.getVisibilityProtected()); myRbAccessorPrivate.setText(RefactoringBundle.getVisibilityPrivate()); myRbAccessorPackageLocal.setText(RefactoringBundle.getVisibilityPackageLocal()); ButtonGroup fieldGroup = new ButtonGroup(); fieldGroup.add(myRbFieldAsIs); fieldGroup.add(myRbFieldPackageLocal); fieldGroup.add(myRbFieldPrivate); fieldGroup.add(myRbFieldProtected); ButtonGroup methodGroup = new ButtonGroup(); methodGroup.add(myRbAccessorPackageLocal); methodGroup.add(myRbAccessorPrivate); methodGroup.add(myRbAccessorProtected); methodGroup.add(myRbAccessorPublic); myCbEncapsulateGet.setSelected(true); myCbEncapsulateSet.setSelected(true); ActionListener checkboxListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (myCbEncapsulateGet.equals(e.getSource())) { if (!myCbEncapsulateGet.isSelected()) { myCbEncapsulateSet.setSelected(true); } } else { // myCbEncapsulateSet is the source if (!myCbEncapsulateSet.isSelected()) { myCbEncapsulateGet.setSelected(true); } } int[] rows = myTable.getSelectedRows(); myTableModel.fireTableDataChanged(); TableUtil.selectRows(myTable, rows); } }; myCbEncapsulateGet.addActionListener(checkboxListener); myCbEncapsulateSet.addActionListener(checkboxListener); myRbFieldAsIs.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (myRbFieldAsIs.isSelected()) { myCbUseAccessorWhenAccessibleValue = myCbUseAccessorsWhenAccessible.isSelected(); myCbUseAccessorsWhenAccessible.setSelected(true); myCbUseAccessorsWhenAccessible.setEnabled(false); } else { myCbUseAccessorsWhenAccessible.setEnabled(true); myCbUseAccessorsWhenAccessible.setSelected(myCbUseAccessorWhenAccessibleValue); } } } ); myCbUseAccessorsWhenAccessible.setSelected( JavaRefactoringSettings.getInstance().ENCAPSULATE_FIELDS_USE_ACCESSORS_WHEN_ACCESSIBLE ); myCbUseAccessorWhenAccessibleValue = myCbUseAccessorsWhenAccessible.isSelected(); myRbFieldPrivate.setSelected(true); myRbAccessorPublic.setSelected(true); Box leftBox = Box.createVerticalBox(); myCbEncapsulateGet.setPreferredSize(myCbUseAccessorsWhenAccessible.getPreferredSize()); leftBox.add(myCbEncapsulateGet); leftBox.add(myCbEncapsulateSet); leftBox.add(Box.createVerticalStrut(10)); leftBox.add(myCbUseAccessorsWhenAccessible); JPanel leftPanel = new JPanel(new BorderLayout()); leftPanel.setBorder(IdeBorderFactory.createTitledBorder( JavaRefactoringBundle.message("encapsulate.fields.encapsulate.border.title"))); leftPanel.add(leftBox, BorderLayout.CENTER); leftPanel.add(Box.createHorizontalStrut(5), BorderLayout.WEST); JPanel encapsulateBox = new JPanel(new BorderLayout()); encapsulateBox.add(leftPanel, BorderLayout.CENTER); myJavadocPolicy = new DocCommentPanel(JavaBundle.message("encapsulate.fields.dialog.javadoc.title")); encapsulateBox.add(myJavadocPolicy, BorderLayout.EAST); boolean hasJavadoc = false; for (PsiField field : myFields) { if (field.getDocComment() != null) { hasJavadoc = true; break; } } myJavadocPolicy.setVisible(hasJavadoc); Box fieldsBox = Box.createVerticalBox(); fieldsBox.add(myRbFieldPrivate); fieldsBox.add(myRbFieldPackageLocal); fieldsBox.add(myRbFieldProtected); fieldsBox.add(myRbFieldAsIs); JPanel fieldsVisibilityPanel = new JPanel(new BorderLayout()); fieldsVisibilityPanel.setBorder(IdeBorderFactory.createTitledBorder( JavaRefactoringBundle.message("encapsulate.fields..encapsulated.fields.visibility.border.title"))); fieldsVisibilityPanel.add(fieldsBox, BorderLayout.CENTER); fieldsVisibilityPanel.add(Box.createHorizontalStrut(5), BorderLayout.WEST); Box methodsBox = Box.createVerticalBox(); methodsBox.add(myRbAccessorPublic); methodsBox.add(myRbAccessorProtected); methodsBox.add(myRbAccessorPackageLocal); methodsBox.add(myRbAccessorPrivate); JPanel methodsVisibilityPanel = new JPanel(new BorderLayout()); methodsVisibilityPanel.setBorder(IdeBorderFactory.createTitledBorder( JavaRefactoringBundle.message("encapsulate.fields.accessors.visibility.border.title"))); methodsVisibilityPanel.add(methodsBox, BorderLayout.CENTER); methodsVisibilityPanel.add(Box.createHorizontalStrut(5), BorderLayout.WEST); Box visibilityBox = Box.createHorizontalBox(); visibilityBox.add(fieldsVisibilityPanel); visibilityBox.add(Box.createHorizontalStrut(5)); visibilityBox.add(methodsVisibilityPanel); Box box = Box.createVerticalBox(); box.add(encapsulateBox); box.add(Box.createVerticalStrut(5)); box.add(visibilityBox); JPanel boxPanel = new JPanel(new BorderLayout()); boxPanel.add(box, BorderLayout.CENTER); boxPanel.add(Box.createVerticalStrut(5), BorderLayout.NORTH); panel.add(boxPanel, BorderLayout.SOUTH); return panel; }