Although Visual J++ provides Class Outline and WFC Component Builder to help you add methods, member variables, properties, events, and classes to a project, you can also add these to your project by typing the code directly into your .java file from the Text editor. When you add the code for new classes and class members to a .java file, IntelliSense immediately displays the appropriate icon for the new class or class member in your project's Class Outline.
The following procedure demonstrates the dynamic updating of Class Outline when a new class and method is added to a source file from the Text editor.
Note The code examples in this and the following topic, Adding Javadoc Comments to Source Files, were created with a Visual J++ Console Application project. You may use any existing Visual J++ project to reproduce the results of these scenarios. If you want to create a Console Application project for the following procedures, see Creating a Console Application and follow the steps to create and open the project before proceeding.
To add a new class to Class Outline from the Text editor
main()
method (Class1 .java by default).Visual J++ opens the Text editor and loads your .java file. The file is now ready for editing.
Class Outline appears with a collapsed tree view of your file.
Class1,
add the following code to your .java source file:class Greeting
{
}
Greeting
class you've just created.Note When you use the Text editor to move the insertion point in the source file, Class Outline does not indicate which definition has been navigated to. To synchronize Class Outline with the source file, right-click the declaration in the Text editor and click Sync Class Outline on the shortcut menu.
To add a new method to Class Outline from the Text editor
Greeting
class to display the icons for Superclasses and Inherited Members.Greeting
class:public static String hello()
{
String strGreet = new String("Hello World!");
return strGreet;
}
hello()
method you've just created.Note When you use the Text editor to move the insertion point in the source file, Class Outline does not indicate which definition has been navigated to. To synchronize Class Outline with the source file, right-click the declaration in the Text editor and click Sync Class Outline on the shortcut menu.
hello()
method of the Greeting
class, add the following code to your application's main()
method:System.out.println(Greeting.hello());
return;
return
" (the last statement of this program's code). Click the right mouse button and select Run To Cursor from the shortcut menu.Hello World!
To add a Javadoc comment to the new hello()
method, see Adding Javadoc Comments to Source Files.