Copying a Class

See Also

To copy a class, either to the same or to another package, and to change the code that references that class:

  1. In the Projects window or the Source Editor window, right-click the class and choose Refactor > Copy from the contextual menu.
  2. In the Copy Class dialog box, select the package from the To Package combo box or type the fully qualified package name, such as com.myCom.myPkg.
  3. If you click Refactor, the IDE applies the changes automatically and skips the remaining steps. If you click Preview, 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. Click Do Refactoring to apply the selected changes.

To copy a class without doing refactoring:

  1. In the Projects window, manually copy the class to another package.

    You can cut and paste the class, or you can use drag and drop.

  2. In the Copy Class dialog box, select the Copy Without Refactoring checkbox.
  3. Click Next.
See Also
Renaming a Class or Interface
Finding Class, Method, and Field Usages
Undoing Refactoring Changes

Legal Notices