Adding classes, interfaces, exceptions and packages
Adding packages, classes, interfaces, and exceptions to a Java class model can be
done in the explorer window.
The following steps show you how to add packages and classes (interface or exception too) to your model.
- Right-click the class model icon in the explorer window.
- In the pop-up menu, choose Add > Package.
- To add a package to the package, right-click the first package in the explorer
window and again choose Add > package from the pop-up menu.
- Right-click the Class Model, and from the pop-up menu, choose Add > Class.
You can add as many classes to a class model or to a package as you want.
Made a mistake? You can delete an object in the ModelSphere explorer
window by first selecting the item, then by clicking the Delete tool in
the Edit toolbar. Clicking the undo icon repeatedly, on the other hand,
will undo operations one at a time.
If, at any time, you want to expand a hierarchy in the explorer window,
click the ‘handle’
next to a category.
If you choose to create your model using the diagram window, you must also select Show Diagram.
Normally, changes made in the graphic window are automatically
reflected in ModelSphere’s explorer window.
If your model requires the creation of several classes, interfaces, exceptions
or packages, it may be quicker to create a diagram for the Java
class model and add the items directly in the diagram.
The following section explains how to do this.
Adding classes, interfaces, exceptions and packages using
the graphic window
To add a class, interface, exception, or package to a model using the graphic window
(rather than the explorer window), use the appropriate tool in the Java creation
toolbar: the Class Creation tool
, Interface Creation tool
, Exception Creation
tool
or Package Creation tool
.
Before you can add classes to the packages using the diagram window, you must
create this diagram for each package.
- Right-click the package in the Explorer window and choose Add >
Diagram from the pop-up menu.
- To display the diagram, right-click it and, from the pop-up menu, select
Show Diagram. Using the graphic window, you will now add classes, exception and interface
to the package.
- Select the Class Creation tool
in the Java creation toolbar and click a free
space in the graphic window. A class will appear.
- You can do the same operation with other creation tools for exceptions, interfaces and packages.