Exploring VisualAge For Java


VisualAge for Java is a great tool for beginning and advanced Java programmers alike. The heart of VisualAge is the workbench, which allows multiple views (such as Project, Package, Class, etc...) of all of the code in the workspace. From the workbench, you can launch applications/applets, debug code, manage code revisions, and even design GUIs visually. Extensive help is available with VisualAge including numerous tutorials.

Navigating through the large amount of source code in the VisualAge workspace is an important skill. In this Magercise, you will learn how to search for definitions and references to classes and methods.

Most development environments can only search with simple text searches like a word processor. VisualAge allows you to search your Java code using knowledge of the code structure such as "it is a class name". This alone gives programmers a significant advantage over other development environments.

Tasks

Perform the following tasks:

  1. Finding elements within the workspace. Using the popup menu from within the project pane of the workbench (right-click the mouse), select "Search inside...". In the resulting dialog box, type "Button" for the "Name" text field and make sure that the the pulldown menus all look like the following.

    When you click "Start", VisualAge will search for all "Button" class or interface declarations in the entire workspace. VisualAge should find one definition (in package java.awt) and a new double-paned window should appear containing java.awt.Button. Double-click on that item and a browser will appear containing a list of all the methods in java.awt.Button. Select method getActionCommand and your browser should look something like:

  2. If you look at the tabs above the methods pane, you will see a series of tabs, with "Methods" selected. Click on the "Hierarchy" tab to see where class java.awt.Button fits in the class hierarchy:

    Close this browser and go back to the workbench.

  3. Click the flashlight icon under the menu bar of the workbench to bring back up the search dialog box. Last time, you searched for definitions of "Button". This time search for references to "Button". Make sure that the dialog box looks like the following and click "Start":

    A list of references to "Button" will appear. Click on any of the listed references and the Java source code that references "Button" will appear in the bottom pane:

  4. If you know the name of a class, interface, project, or package that you would like to examine, you can jump directly there instead of having VisualAge search the entire workspace. From the "Selected" menu of the workbench, choose "Go To..." and then choose submenu item "Class/Interface" which will bring up a dialog box containing the list of all classes and interfaces. Type the two letter "Bu" and you will see that VisualAge automatically filters the list down to the possible completions:

    You may continue typing or simply select any of the listed class names.

  5. Often, you will not know the exact class you are looking for or you may simply want to explore what is available in the various projects. To explore in this manner, click on the "Classes" tab of the workbench and a hierarchical view of all classes in the workspace will appear. Using the scroll bar, you can wander through the various classes. Clicking on one of the class names, will list the methods to the right and the source code below. For example, consider the following.

  6. When you are interesting in the class hierarchy (that is, which class extends which class), a graphical tree view is useful. With the workbench "Classes" tab selected, look for tree view icon:
    in the upper right corner of the class list (right above the scroll bar). Click that icon and the class hierarchy should appear similar to the following.

    Double-clicking on a tree node expands it to show any subclasses. Selecting a node shows the methods for that class.

The task numbers above are linked to the step-by-step help page. Also available is a complete solution to the problem, and expected behavior, to demonstrate it.

Copyright © 1996-1997 MageLang Institute. All Rights Reserved.