Creating New Code

As you work with the IDE to create and change user interfaces, properties, and so on, Java source files are automatically generated and updated in the Source Editor. Code that is automatically generated by the Form Editor appears in blue-shaded areas of guarded text that you cannot edit directly, although you can affect the way such code is generated.

You can type in your own code at any time in the nonguarded areas of the Source Editor. The Source Editor has many shortcuts to make this easier, including automatic formatting and automatic text completion with macros, abbreviations, and the code completion and word match features.

In addition to these shortcuts (which you can read about in the links below), the Source Editor provides shortcuts for adding new Java elements with a minimum of typing.

To generate the basic structure for a new class or interface:

  1. Move the insertion point to an area outside of any existing class or interface.
  2. Right-click and choose New and choose Class or New and choose Interface from the contextual menu. A customizer dialog box appears that enables you to specify elements of the new class or interface declaration.
  3. Fill in the customizer dialog box and click OK. The structure for your new class or interface appears in the Source Editor after any existing classes or interfaces.

To generate text for a new initializer, field, constructor, method, inner class, or inner interface:

  1. Move the insertion point to an area within a class or interface.
  2. Right-click and choose the desired object from the New submenu of the contextual menu. Unless you choose Initializer, a customizer dialog box appears enabling you to specify the appropriate elements of the new Java object.
  3. Fill in the customizer dialog box and click OK. The new text might appear in the Source Editor after other existing Java objects.
Tip When you generate Java text with the New item on the contextual menu, you might need to scroll to find your new text. It is normally added in an appropriate place after existing Java objects.
See also
Working With Source Code
Guarded Text

Formatting Code
Using Code Completion
Using Macros and Abbreviations
Using the Word Match Feature

Legal Notices