Overriding and Implementing Methods

See Also 

The IDE has the following two mechanisms to generate code for implementing or overriding methods that are defined in other classes:

To use code completion to generate code to override or implement a method:

  1. In the class declaration, use the extends keyword to extend a class, or use the implements keyword to implement an interface.
  2. At the beginning of the line where you want to place the method, press Ctrl-Spacebar and select the method from the code completion dialog box.

    The method declaration is inserted into the file. You can then code the method body in the Source Editor.

To use the Override Methods command:

  1. In the class declaration, use the extends keyword to extend a class, or use the implements keyword to implement an interface.
  2. Right-click a Java file in the Projects window and choose Source > Override Methods from the pop-up menu or press Ctrl-I.

    The Override and Implement Methods dialog box is displayed with all of the available methods listed in the Available Superclass and Interface Methods panel. The IDE filters out final, static, private, and package-private methods.

    Use the checkboxes at the top of the dialog box to fine-tune the methods displayed in the list:

  3. In the Available Superclass and Interface Methods panel, select the methods you want to override.
  4. If you want the methods that are generated in your class to contain calls to the superclass method, select the Generate Super Calls checkbox.
  5. To copy the Javadoc comments for the selected methods into your source file, select the Copy Javadoc checkbox.
  6. Click OK.

    The methods are created in your class's source file with proper declarations and empty bodies or superclass calls. You can then code the method body in the Source Editor.

Overridden methods are marked with a override glyph  glyph in the method's left margin in the Source Editor. Methods that are implemented from an interface or an abstract class are marked with implement glyph  glyph. Hold the pointer over the glyph to view a tooltip with the fully-qualified name of the class that contains the overriden or implemented method. .

See Also
Using Code Completion
Using Editor Hints to Fix Code
Using the Word Match Feature

Legal Notices