- Opening the Source Editor
- Managing Automatic Insertion of Closing Characters
- Displaying Line Numbers
- Generating Code Snippets without Leaving the Keyboard
- Using Code Completion
- Inserting Snippets from Code Templates
- Using Editor Hints to Generate Missing Code
- Matching Other Words in a File
- Generating Methods to Implement and Override
- Generating JavaBeans Component Code
- Creating and Using Macros
- Creating and Customizing File Templates
- Handling Imports
- Displaying Javadoc Documentation While Editing
- Formatting Code
- Text Selection Shortcuts
- Navigating within the Current Java File
- Navigating from the Source Editor
- Searching and Replacing
- Deleting Code Safely
- Changing a Method's Signature
- Encapsulating a Field
- Moving a Class to a Different Package
- Moving Class Members to Other Classes
- Creating a Method from Existing Statements
- Creating an Interface from Existing Methods
- Extracting a Superclass to Consolidate Common Methods
- Changing References to Use a Supertype
- Unnesting Classes
- Tracking Notes to Yourself in Your Code
- Comparing Differences Between Two Files
- Splitting the Source Editor
- Maximizing Space for the Source Editor
- Changing Source Editor Keyboard Shortcuts
Moving a Class to a Different Package
If you want to place a class in a different package, you can use the IDE's refactoring features to move the class and then update references to that class automatically throughout your project.
To move a class:
- In the Projects window, drag the class from its current package to the package you want to place it in. (You can also use the Cut and Paste commands in the contextual menus or the corresponding keyboard shortcuts.)
-
In the Move Class or Move Classes dialog box (shown in Figure 5-16), click Next after verifying that the To Package and This Class fields reflect the destination package and the class you are moving. (If you move multiple classes, a List of Classes text area is shown instead of the This Class field.)
Figure 5-16 Move Classes dialog box
If you have deselected the Preview All Changes checkbox, the changes are applied immediately.
If you leave the Preview All Changes checkbox selected, the Refactoring window appears with a preview of the changes.
-
In the Refactoring window (shown in Figure 5-17), look at the preview of the code to be changed. If there is a modification that you do not want to be made, deselect the checkbox next to the line for that change.
Figure 5-17 Refactoring window
-
Click Do Refactoring.
If you later find that the refactoring has had some consequences that you would like to reverse, you can choose Refactor | Undo.