Java Reference
In-Depth Information
As an example, Figure 5 shows how two Canvas3D, canvas3D1 and canvas3D2 with
a control panel each, can be added to viewManager, an instantiated object of ViewMan-
ager.
If the code sequence is in the wrong order as illustrated in Figure 6, an error will re-
sult. Specifically, this code segment will add canvas3D1 without any control panel, while
canvas3D2 will have only one control panel. This is despite the two attempts to create two
control panels, with the second one overwriting the first one.
addInG controls
Since ViewManager only helps us to position the controls for a Canvas3D object, the
creation of these controls and their ActionListener have to be carried out manually. Note
that, in this process, we need to invoke the createControlPanel method first. Specifically,
the addControl methods illustrated in Figure 7 can only be used in conjunction with the
appropriate createControlPanel method. The setControlPanel method cannot be used for
the addition of controls.
Figure 7. addControl method summary
JComponent viewManager.addControl(JComponent jComponent);
JComponent viewManager.addControl(JComponent jComponent, int height, int width);
JComponent viewManager.addControl(JComponent jComponent, int index);
JComponent viewManager.addControl(JComponent jComponent, int index, int height, int width);
JComponent viewManager.addControl(JComponent jComponent, int row, int column, int height,
// int width);
// jComponent - an object from JComponent or any of its subclasses to be added
// index - index of the jComponent with respect to other jComponent objects
// row - row for adding jComponent, with respect to other jComponent objects
// column - column for adding jComponent, with respect to other jComponent objects
// height - number of rows jComponent would stretch across
// width - number of columns jComponent would stretch across
Figure 8. Using addControl
1.
viewManager.addControl (title, 1, 3);
2.
viewManager.addControl (minus);
3.
viewmanager.addControl (value);
4.
viewManager.addControl (plus);
Search WWH ::




Custom Search