An excellent platform independent vector drawing gift for you!
Home | Products | Download | Documentations | Order Now | Contact |  
 
FAQs
Quick Install
Developer Guide
ScreenShots
Award
 
    Java.net
    AbleStable
    Softpedia
    FreeTrialSoft
    FreshMeat
    Download32
    More...
  Developer Guide(Cooperate with JMF) - JFImagine.com

[Prior]   [Top]   [Next]

9. Cooperate with JMF(Java Media Framework) in JFDraw


       Run JFDraw on JMF movies.

    If you are familiar with JMF(Java Media Framework), you way want to run JFDraw on a JMF movie. So you can draw some vector graphs on those movies, make text tags, etc.

   You know, JMF is almost AWT based, and JFDraw is totally Swing based. How can those two things work together?

   Don't worry about this. Sun Microsystems has made JMF works well in a Swing container(e.g. JPanel), and also, we have finished some necessary modifications on JFDraw. So JFDraw can now paint on JMF movies without overdrawing them,whenever the movies are being played or stopped.

       Principles and sample codes of a JMF enabled JFDraw.

1. We need a subclass of DrawCanvas.

In the sample source codes, we named this subclass as JMFDrawCanvas, this class is used to encapsulate a JMF player and its movie operations, it replaces the main drawing area of DrawCanvas as the VisualComponent of a JMF player,and paints movies and JFDraw shapes each time the repaint method was called.

2. We also need a subclass of DrawPane.

We also created a JMFDrawPane to replace DrawPane class,this class is used to pack a JMFDrawCanvas (but not a DrawCanvas) , to tell JMF to use SWING instead of AWT, to finalize JMF player when exit.

3. Now let's take a glance of the codes of this sample.

//Action: create a JMF draw panel
//Desc: A JMFDrawPane object packed a JMFDrawCanvas and rulers. You need to tell //JMFDrawPane to open an media file.

drawPane =new JMFDrawPane("1.avi");

//set an initial size for drawPane
drawPane.setPreferredSize(new Dimension(400,300));

setLayout(new BorderLayout());
add("Center",drawPane);
add("South",getControlPanel());

.....

   Screenshot of this sample.

    Now you can take a look at this JMF enabled JFDraw:

   

 

        To get full source code of this sample.

    You can download the full sample source code package here. Then open the file at sample8/*.java for detail informations.

    Note: You may need these two files, JMF library and the example movie(1.avi), please download those two files here. And, please don't forget to download a latest JMF install package, then install this package on your machine.

 

[Prior]   [Top]   [Next]