␡
- 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
This chapter is from the book
Generating Methods to Implement and Override
When you extend a class or implement an interface, you have abstract methods that you need to implement and possibly non-abstract methods that you can override. The IDE has several tools that help you generate these methods in your class:
- Editor hints. When you add the implements or extends clause, a lightbulb ( ) icon appears in the left margin. You can click this icon or press AltEnter to view a hint to implement abstract methods. If you select the hint and press Enter, the IDE generates the methods for you. This hint only is available when your cursor is in the line of the class declaration.
-
Code completion. You can generate methods to implement and override individually by pressing Ctrl-Space and choosing the methods from the code completion box. As shown in Figure 5-7, methods to implement or override are marked implement and override, respectively.
Figure 5-7 Code completion box showing methods to implement and methods available to be overridden
- Override and Implement Methods dialog box. You can use this dialog box (shown in Figure 5-8) for generating any combination of the available implementable or overridable methods. This feature also enables you to generate calls to the super implementation of the methods within the body of the generated methods. To open this dialog box, choose Source | Override Methods or press Ctrl-I. To select multiple methods, use Ctrl-click.
Figure 5-8 Override and Implement Methods dialog box