next up previous
Next: Interacting With Java Layout Up: Quicktime for Java Classes Previous: Quicktime for Java Classes

The QTCanvas Class

To present QuickTime content within Java, you need a mechanism for interacting with the Java display and event system. This is provided through the services of the QTCanvas class and its client, an object that implements the Drawable interface. QTCanvas is a specialized canvas that supplies access to the native graphics environment and offers expanded display functionality.

QTCanvas encapsulates much of the display and presentation functionality of the QuickTime for Java API. It is responsible for ``punching a hole'' within the Java display surface and telling its client that it can draw to this display surface and receive events that occur therein. Its clients are generally some kind of QuickTime object, and the events it receives may be mouse or key events. An instance of a QTCanvas object can display any object that implements the Drawable interface.

The client of a QTCanvas object is called Drawable because QuickTime generally uses the word ``draw'' -- for example, MCDraw. Java uses the word ``paint,'' so this enables us to make a distinction between Java objects that ``paint'' and QuickTime objects that ``draw.''

Your code can interact with the QTCanvas methods as with those of any java.awt.Component. The QTCanvas delegates calls as appropriate to its drawing client. A client essentially draws itself in the display area of a QTCanvas. If the client is a QTDrawable, the QTCanvas also gets the graphics structure (QDGraphics) of the native implementation of the canvas's peer and sets this QDGraphics as the destination QDGraphics of such a client. All QTDrawable objects require a destination QDGraphics in which to draw.

Using the setClient() method, you can associate a new client, a Drawable object, with this QTCanvas. The flag determines if awt performs a layout and how the client is integrated with the canvas. If the flag is false, the new client takes on the current size and position of the canvas. If the flag is true, then awt lays out the canvas again, using the initial size of the client and the resize flags to resize the canvas and its client. The getClient() method returns the Drawable object currently associated with this QTCanvas.



 
next up previous
Next: Interacting With Java Layout Up: Quicktime for Java Classes Previous: Quicktime for Java Classes
Dave Marshall
10/4/2001