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:
- Right-click your Java file's class node (
)
in the Explorer window and choose Override Methods from the contextual menu.
The Override Methods dialog box is displayed. The All Inherited Classes
list contains all the superclasses that your class inherits from. This list also contains
all interfaces that your class implements and their superclasses.
- Select one or more items from the All Inherited Classes list to display
methods declared in those classes or interfaces.
The Available Methods field lists all of the selected items' methods that
can be overriden. The IDE filters out final, static, private, and package-private
methods.
Use the options to the right of the Available Methods list to fine-tune
the methods displayed in the list:
- Select Inherited to show not only methods in the Inherited Classes
list, but also methods that are in their superclasses up to java.lang.Object.
This option is useful if you are looking for a method but you do not know
exactly which class declares it.
- Select Only Abstract to show only methods that are explicitly declared
abstract.
- In the Available Methods list, select the methods you want to override.
Click Add to add the selected methods to the bottom panel.
- If you want the methods that are 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. This list also contains all of the methods that were already redefined in your source
code before you ran the Override Methods tool.
- 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.
Legal Notices