Converting an Anonymous Inner Class to a Regular Inner Class
See Also
You can use the Convert Anonymous Class to Inner command to convert an
anonymous class to an inner class that contains a name and constructor. When you
use this operation, a new inner class is created and the anonymous inner class
is replaced with a call to the new inner class.
To use the Convert Anonymous Class to Inner operation:
- In the Source Editor, place the insertion point in the anonymous inner class that you
want to convert.
- Choose Refactor > Convert Anonymous Class to Inner.
The Convert Anonymous Class to Inner dialog box appears.
- In the Inner Class Name field, type a name for the inner class to be created.
- In the Access field, select the access level that you want for the class.
- If you want the class to be static, select the Declare Static checkbox.
- (Optional) If the class has multiple constructor parameters, you can use the Move Up
or Move Down buttons to change the order of the parameters.
- (Optional) If you want to review the changes before they are made,
select the Preview All Changes checkbox.
- Click Next. If you have not selected the Preview All Changes checkbox, the IDE applies
the changes automatically and skips the remaining steps.
- If you have selected the Preview All Changes checkbox, the Refactoring window displays the lines of code that will be changed. Review
the list and clear the checkbox of any code that you do not want changed.
- (Optional) Double-click a file name in the Refactoring window to open the file,
or double-click a line of code to open the source file and to position the
cursor on that line of code.
- Click Do Refactoring to apply the selected changes.
- See Also
- Refactoring: Quick Reference
- Moving an Inner Class One Level Up
- Moving a Class Member to a Superclass
- Moving a Class Member to a Subclass
- Moving a Class to Another Java Package
- Renaming a Class or Interface
- Undoing Refactoring Changes
Legal Notices