< Zurück | Inhalt | Weiter >

8.6.2 SetString problems

There is essentially no way to modify the contents of a Text3D object at runtime, for example, to create dynamic or context sensitive labels. The misleading setString method does not destroy the previously generated geometry within the Text3D object, but appends new geometry to the object (figure 8.12). In addition, it does not honor the font, pitch, and other dimensions that were specified when the Text3D object was created. setString( null ) can be used to not display the Text3D object, though this is probably not useful as there would be no way to restore the object without generating more geometry. Note that setString( "" ) causes a NullPointerException. I expect Sun to address these bugs in the immediate future so check your implementation version.


Figure 8.12 Three frames generated by the Text3DTest example. Each subsequent call to setString (called after each frame) adds geometry to the Text3D. The result is that geometry gets ever more complex