FileDocCategorySizeDatePackage
BasicQTCallbacks.javaAPI DocExample4323Wed Nov 10 12:37:56 GMT 2004com.oreilly.qtjnotebook.ch02

BasicQTCallbacks

public class BasicQTCallbacks extends Frame implements ActionListener

Fields Summary
Button
revButton
Button
stopButton
Button
startButton
Button
fwdButton
MyQTCallback
myCallback
Movie
theMovie
Constructors Summary
public BasicQTCallbacks(Movie m)

        super ("Basic QT Player");
        theMovie = m;
        myCallback = new MyQTCallback (m);
        QTComponent qc = QTFactory.makeQTComponent (m);
        Component c = qc.asComponent();
        setLayout (new BorderLayout());
        add (c, BorderLayout.CENTER);
        Panel buttons = new Panel();
        revButton = new Button("<");
        revButton.addActionListener (this);
        stopButton = new Button ("0");
        stopButton.addActionListener (this);
        startButton = new Button ("1");
        startButton.addActionListener (this);
        fwdButton = new Button (">");
        fwdButton.addActionListener (this);
        buttons.add (revButton);
        buttons.add (stopButton);
        buttons.add (startButton);
        buttons.add (fwdButton);
        add (buttons, BorderLayout.SOUTH);
        pack();
    
Methods Summary
public voidactionPerformed(java.awt.event.ActionEvent e)

        try {
            if (e.getSource() == revButton)
                theMovie.setRate (theMovie.getRate() - 0.5f);
            else if (e.getSource() == stopButton)
                theMovie.stop();
            else if (e.getSource() == startButton)
                theMovie.start();
            else if (e.getSource() == fwdButton)
                theMovie.setRate (theMovie.getRate() + 0.5f);
        } catch (QTException qte) {
            qte.printStackTrace();
        }
    
public static voidmain(java.lang.String[] args)

        try {
            QTSessionCheck.check();
            QTFile file =
                QTFile.standardGetFilePreview (QTFile.kStandardQTFileTypes);
            OpenMovieFile omFile = OpenMovieFile.asRead (file);
            Movie m = Movie.fromFile (omFile);
            Frame f = new BasicQTCallbacks (m);
            f.pack();
            f.setVisible(true);
            m.start();
        } catch (Exception e) {
            e.printStackTrace();
        }