home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 2.toast / pc / sample code / quicktime / quicktime for java / zoo tutorial / module10- qtzoo / completed source / zoo.java < prev    next >
Encoding:
Java Source  |  2000-09-28  |  5.5 KB  |  159 lines

  1. import java.awt.Color;
  2. import java.awt.GridBagLayout;
  3. import java.awt.GridBagConstraints;
  4.  
  5. import quicktime.QTSession;
  6. import quicktime.QTException;
  7. import quicktime.app.display.FullScreenWindow;
  8. import quicktime.std.movies.FullScreen;
  9.  
  10. import com.apple.mrj.MRJApplicationUtils;
  11. import com.apple.mrj.MRJQuitHandler;
  12.  
  13.  
  14. /**
  15.  * QTZoo Module 9 - Using Full Screen Mode
  16.  * This application requires QuickTime for Java
  17.  *
  18.  * @author Levi Brown
  19.  * @author Michael Hopkins
  20.  * @author Apple Computer, Inc.
  21.  * @version 9.0 4/10/2000
  22.  * 
  23.  * Copyright:     © Copyright 1999 Apple Computer, Inc. All rights reserved.
  24.  *    
  25.  * Disclaimer:    IMPORTANT:  This Apple software is supplied to you by Apple Computer, Inc.
  26.  *                ("Apple") in consideration of your agreement to the following terms, and your
  27.  *                use, installation, modification or redistribution of this Apple software
  28.  *                constitutes acceptance of these terms.  If you do not agree with these terms,
  29.  *                please do not use, install, modify or redistribute this Apple software.
  30.  *
  31.  *                In consideration of your agreement to abide by the following terms, and subject
  32.  *                to these terms, Apple grants you a personal, non-exclusive license, under Apple’s
  33.  *                copyrights in this original Apple software (the "Apple Software"), to use,
  34.  *                reproduce, modify and redistribute the Apple Software, with or without
  35.  *                modifications, in source and/or binary forms; provided that if you redistribute
  36.  *                the Apple Software in its entirety and without modifications, you must retain
  37.  *                this notice and the following text and disclaimers in all such redistributions of
  38.  *                the Apple Software.  Neither the name, trademarks, service marks or logos of
  39.  *                Apple Computer, Inc. may be used to endorse or promote products derived from the
  40.  *                Apple Software without specific prior written permission from Apple.  Except as
  41.  *                expressly stated in this notice, no other rights or licenses, express or implied,
  42.  *                are granted by Apple herein, including but not limited to any patent rights that
  43.  *                may be infringed by your derivative works or by other works in which the Apple
  44.  *                Software may be incorporated.
  45.  *
  46.  *                The Apple Software is provided by Apple on an "AS IS" basis.  APPLE MAKES NO
  47.  *                WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
  48.  *                WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  49.  *                PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
  50.  *                COMBINATION WITH YOUR PRODUCTS.
  51.  *
  52.  *                IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
  53.  *                CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  54.  *                GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  55.  *                ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
  56.  *                OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
  57.  *                (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
  58.  *                ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  59.  * 
  60.  */
  61.  
  62. public class Zoo implements MRJQuitHandler, Runnable //!! added Runnable !!
  63. {
  64.     /**
  65.      *  Zoo constructor
  66.      */
  67.     public Zoo() 
  68.     {
  69.         MRJApplicationUtils.registerQuitHandler(this);            // register handler for command-Q
  70.         
  71.         //-- Create new progress bar object                       --
  72.         //-- Insert "1 Zoo- create progress" source clipping here --
  73.         progress = new Progress(78);        // number of steps in our loading procedure
  74.         try
  75.         {
  76.             window = new FullScreenWindow(new FullScreen());    // create a new fullscreen window
  77.             window.setBackground (Color.black);                    // color window black
  78.             
  79.             window.setLayout(new GridBagLayout());
  80.             gbc = new GridBagConstraints();
  81.             gbc.gridx = 1;
  82.             gbc.gridy = 1;
  83.             gbc.gridwidth = 1;
  84.             gbc.anchor = GridBagConstraints.CENTER;
  85.             gbc.fill = GridBagConstraints.NONE;
  86.             
  87.             //-- Add progress object to window                        --
  88.             //-- Insert "3 Zoo- add progress" source clipping here --
  89.             window.add(progress);
  90.             progress.setVisible(true);
  91.  
  92.             window.show();
  93.             //-- Create and start new thread                         --
  94.             //-- Insert "4 Zoo- create thread" source clipping here --
  95.             Thread thread = new Thread(this);    // create a thread to load our media asynchonously
  96.             thread.start();
  97.             
  98.             //!! We don't need the following because we are now a runnable !!
  99.             /* run(); */
  100.         }
  101.         catch (QTException exc)
  102.         {
  103.             exc.printStackTrace();
  104.         }
  105.     }
  106.     
  107.     /**
  108.      * Main body of class. Creates main window, and displays it
  109.      */
  110.     public void run()
  111.     {
  112.         mainFrame = new MainFrame(window, progress);
  113.         
  114.         //-- Remove progress bar                                     --
  115.         //-- Insert "5 Zoo- remove progress" source clipping here --
  116.         window.remove(progress);
  117.         mainFrame.setVisible(true);
  118.         ((GridBagLayout)window.getLayout()).setConstraints(mainFrame, gbc);
  119.         window.add(mainFrame);
  120.         mainFrame.invalidate();
  121.         window.validate();
  122.     }
  123.     
  124.     /**
  125.      * Handles quitting the application.
  126.      * This routine gets called by the MRJToolkit when the
  127.      * application is about to quit.
  128.      */
  129.     public void handleQuit()
  130.     {
  131.         mainFrame.handleQuit();
  132.     }
  133.  
  134.     /**
  135.      * Main entry point of our program
  136.      */
  137.     static public void main(String[] args) 
  138.     {
  139.         try
  140.         {
  141.             QTSession.open();            // Initialize QuickTime 
  142.             new Zoo( );
  143.         }
  144.         catch (Exception e) 
  145.         {
  146.             e.printStackTrace();
  147.             QTSession.close();            // Shut down QuickTime and dispose of native context
  148.         }
  149.     }
  150.     
  151.     protected MainFrame mainFrame;    
  152.     protected FullScreenWindow window;
  153.     protected GridBagConstraints gbc;
  154.     
  155.     //-- Declare progress object data member                      --
  156.     //-- Insert "2 Zoo- declare progress" source clipping here --
  157.     protected Progress progress;
  158. }
  159.