Java Reference
In-Depth Information
Yet another way is add a control panel is to use ViewManager to create an empty panel
first and then add the controls later. The method that can be used for this purpose is il-
lustrated in Figure 4.
Invoking createControlPanel() without any parameter will create a control panel at
defaults given by location = ViewManager.BOTTOM_CONTROL, row = 1, and column
= 3. Although this default is only for 3 controls in a single row, more controls can in fact
be added through the usual wrapping process.
Note however that the setControlPanel and createControlPanel methods are applicable
only to the last Canvas3D added. Also, each Canvas3D can only have one control panel.
Thus, invoking one of these methods will overwrite any control panel that has been set or
created earlier.
Figure 4. createControlPanel method of ViewManager
JPanel viewManager.createControlPanel();
JPanel viewManager.createControlPanel(int row, int column);
JPanel viewManager.createControlPanel(String location, int row, int column);
// location - May be ViewManager.TOP_CONTROL, ViewManager.RIGHT_CONTROL,
// ViewManager.BOTTOM_CONTROL or ViewManager.LEFT_CONTROL
// specifying the position for the jPanel to be added with respect to the Canvas3D
// row - total number of rows of controls to be added
// column - total number of columns of the controls to be added
Figure 5. Using ViewManager correctly
1.
viewManager.add(canvas3D1, “canvas3D1”);
2.
viewManager.createControlPanel();
3.
viewManager.add(canvas3D2, “canvas3D2”);
4.
viewManager.createControlPanel():
Figure 6. Using ViewManager incorrectly
1.
viewManager.add(canvas3D1, “canvas3D1”);
2.
viewManager.add(canvas3D2, “canvas3D2”);
3.
viewManager.createControlPanel();
4.
viewManager.createControlPanel():
Search WWH ::




Custom Search