Moving a Class Member to a Subclass

See Also

You can use the Push Down command to move inner classes, methods, fields to a subclass of their current class.

To initiate the Push Down operation:

  1. In the Source Editor or Projects window, select the class member or class members that you want to move.
  2. Choose Refactor > Push Down.

    The Push Down dialog box appears and displays a list of the class's members. Make sure the checkbox for the member that you want to move is selected.

  3. (Optional) Select the Keep Abstract checkbox for any abstract methods that you want to keep defined in the current class and have implemented in the subclass. The checkbox in the left column must also be checked for the class definition to be copied to the subclass.
  4. (Optional) If you do not want to review the changes before they are made, clear the Preview All Changes checkbox.
  5. Click Next. If you have cleared the Preview All Changes checkbox, the IDE applies the changes automatically and skips the remaining steps.
  6. 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. If the class that you are pushing members from has multiple subclasses and you do not want the members to be pushed to all of them, be sure to clear the checkboxes for the corresponding subclasses.
  7. (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.
  8. Click Do Refactoring to apply the selected changes.
See Also
Refactoring: Quick Reference
Moving a Class Member to a Superclass
Moving a Class to Another Java Package
Renaming a Class or Interface
Undoing Refactoring Changes

Legal Notices