Overriding Methods

When you want to override interface and superclass methods in a Java file, use the Override Methods tool to quickly select from all the available methods.

The Override Methods tool generates the selected methods with proper declarations. You override the methods with your own code in the Source Editor.

To generate code for overriding methods:

  1. Right-click the class node of your Java file in the Explorer window and choose Override Methods from the contextual menu.

    The Override Methods dialog box is displayed.

  2. Select one or more items from the All Inherited Classes list to display methods declared in those classes or interfaces.

    The All Inherited Classes list contains all the superclasses that your class inherits from, as well all interfaces that your class implements and their superclasses.

  3. In the Available Methods list, select the methods you want to override. Click Add to add the selected methods to the bottom panel.

    The Available Methods list shows all methods declared in the classes selected in Step 2 that are appropriate for overriding. The tool filters out final, static, private, and package-private methods so you can be sure that all the methods you see can be overridden.

    Use the options to the right of the Available Methods list to fine-tune the methods displayed in the list:

  4. If you want the methods generated in your class to contain calls to the superclass method, select the Generate Super Calls checkbox at the bottom of the Selected Methods list.

    The Selected Methods list contains all the methods you selected in Step 3, as well as all the methods that were already redefined in your source code before you ran the Override Methods tool.

  5. When the Selected Methods list contains all the methods you want to override, click OK.

    Methods that you added to the Selected Methods list are created in your class's source file with proper declarations and empty bodies or superclass calls.

See also
Synchronizing Source Code
Using the Import Management Tool

Legal Notices