import java.awt.*;
import java.awt.event.*;
import java.io.IOException;
import quicktime.QTSession;
import quicktime.QTException;
import quicktime.app.image.GraphicsImporterDrawer;
import quicktime.app.display.QTCanvas;
import quicktime.app.QTFactory;
import quicktime.io.QTFile;
/**
* QTZoo Module 1 - Initializing QTJava and displaying an image
* This application requires QuickTime for Java
*
* @author Michael Hopkins
* @author Levi Brown
* @author Apple Computer, Inc.
* @version 1.0 10/21/1999
*
* Revision History
* ---------------------------------------------------------------------------
* 12/2/99 MSH added slightly better error handling, reformatting and comments
*
*/
public class Zoo1 extends Frame
{
static public int WIDTH = 640;
static public int HEIGHT = 480;
/**
* Zoo constructor
* @param string title of window
*/
public Zoo1( String s )
{
super(s);
setResizable( false ); // we don't want the window to resize
setBounds( 0, 0, WIDTH, HEIGHT ); // make window 640x480
QTCanvas myQTCanvas = new QTCanvas( QTCanvas.kInitialSize, 0.5F, 0.5F );
add( myQTCanvas );
try
{
QTFile imageFile = new QTFile(
QTFactory.findAbsolutePath( "data/zebra/ZebraBackground.jpg" ));
GraphicsImporterDrawer mapDrawer = new GraphicsImporterDrawer( imageFile );
myQTCanvas.setClient( mapDrawer, true );
}
catch ( IOException e )
{
e.printStackTrace();
}
catch ( QTException e )
{
e.printStackTrace();
}
addWindowListener( new WindowAdapter() // anonymous inner class for handling window events
{
public void windowClosing( WindowEvent we )
{
QTSession.close(); // shut down QT and clean up
dispose(); // destroy window
}
public void windowClosed( WindowEvent we )
{
System.exit( 0 ); // exit to shell
}
});
}
/**
* Main entry point for the application
*/
public static void main( String[] args )
{
try
{
QTSession.open(); // perform native QuickTime initialization
Zoo1 appWindow = new Zoo1( "QTZoo1" ); // create a new application window
appWindow.show(); // make the window visible
appWindow.toFront(); // bring it to the front
}
catch ( Exception e ) // handle any exceptions
{
QTSession.close();
e.printStackTrace();
}
}
}