Java Reference
In-Depth Information
Appendix C
sWInG components
Even though the focus of this topic is on Java 3D, it is not possible to ignore the use of
Swing components completely. This is because, ultimately, a Java 3D virtual world has
to be displayed onto the screen using these. However, through using the ViewManager, a
custom utility class, this distraction, or burden can be significantly relieved, resulting in
codes that are more easily understandably.
ViewManager places each of the Canvas3D inside a JPanel with the title of the Canvas3D
put at the border of that panel. If a Graphical User Interface (GUI) is required, ViewManager
can be invoked to add a sub-JPpanel into the panel that holds the Canvas3D. The layout
within each of the Canvas3D panels can be performed using BorderLayout, while the whole
applet can be organized using GridBagLayout.
Figure 1 shows how ViewManager can be instantiated as well as an example.
If, in the example in Figure 1, the number of Canvas3D objects to be displayed is not
equal to totalRows multiplied by totalColumns, ViewManager will use the value of totalC-
olumns and wrap the Canvas3D objects accordingly. That is, if View Manager is requested
to handle objects in a 1-row by 3-column fashion but there are four Canvas3D objects, the
Search WWH ::

Custom Search