- 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
Creating an Interface from Existing Methods
If you decide to divide your code into API and implementation layers, you can get started on that conversion by using the Extract Interface command to create an interface from methods in an existing class. The Extract Interface command does the following:
- Creates a new interface containing declarations for selected public methods.
- Adds the name of the created interface to the implements clause of the class from which the interface is extracted. (If the interface is extracted from another interface, the name of the newly created interface is added to the extends clause of the other interface.)
To extract an interface from existing methods:
- In the Source Editor or the Projects window, select the class that contains the methods that you want to be extracted into the new interface.
- Choose Refactor | Extract Interface.
In the Extract Interface dialog box, select the checkbox for each method that you want to be declared in the new interface.
If the class from which you are extracting an interface already implements an interface, a checkbox for that interface is included in the Extract Interface dialog box. If you select the checkbox for that interface, the interface is removed from the implements clause of the previously implementing interface and moved to the extends clause of the new interface.
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, 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.
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.