Java Reference
In-Depth Information
to place the objects automatically. The second group is based on the index of the Canvas3D
object to being added. Using this, we can control the sequence of the Canvas3D objects to
be added into the applet. The last group allows complete control on where Canvas3D should
be added, through the row and column of the position of the Canvas3D in the applet.
In the methods for each group, the first one allows one to add just the Canvas3D and its
title. The second one has the additional ability to add a JPanel into the panel that holds the
Canvas3D, with a default position that is below the Canvas3D. With the third method in
each group, we can even specify the position of the JPanel with respect to the Canvas3D.
Most applications will however use just the first method, as ViewManager can also be
used to create the control panel. Nevertheless, the other two methods can also be invoked
to construct a JPanel manually if the needs arise. Note that all of the methods will return
the JPanel that holds the Canvas3D. This gives the handle for any further modifications
to be made.
As a usage example, if viewManager is an instantiated object of ViewManager, and
there is a need to add a Canvas3D canvas3D with the title “test,” we can use the method
viewManager.add(canvas3D, “test”);
This can be repeated to add other Canvas3D objects into the applet. ViewManager will
automatically position the Canvas3D, starting from the top left corner of the applet.
addInG control panel
As previously mentioned, ViewManager allows for the addition of a control panel for each
Canvas3D. However, instead of performing this through the constructor, the SetControlPanel
method illustrated in Figure 3 can also be used for this purpose.
Note that since ViewManager will only help in positioning, the control panel must be
fully programmed before it is added to the Canvas3D.
Figure 3. setControlPanel method of ViewManager
void viewManager.setControlPanel(JPanel jPanel);
void viewManager.setControlPanel(JPanel jPanel, String location);
// jPanel - panel to be added to the most recently added Canvas3D
// location - may be ViewManager.TOP_CONTROL, ViewManager.RIGHT_CONTROL,
// ViewManager.BOTTOM_CONTROL or ViewManager.LEFT_CONTROL for
// specifying the position for adding jPanel with respect to the Canvas3D
Search WWH ::

Custom Search