import java.awt.Graphics; import java.awt.image.BufferedImage; import javax.swing.JFrame; import vxp.PixelSource; import vxp.QTLivePixelSource; public class HelloVideo extends JFrame { //these are all static because they are used in the main method static int kWidth = 320; static int kHeight = 240; static BufferedImage bi; static PixelSource ps ; static boolean running = true; HelloVideo() { //make a new pixel source object from the vxp.jar ps = new QTLivePixelSource(kWidth, kHeight, 300); //attend to the window setTitle("Hello Video"); setSize(kWidth, kHeight); setVisible(true); //this is an ugly mess, I am going to teach you another way to do this //but this is way to field the close window event and shut stuff down properly addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent e) { running = false; ps.killSession(); System.out.println("Killed Video Source"); setVisible(false); dispose(); System.exit(0); } }); } public static void main(String[] Args) { HelloVideo myWorld = new HelloVideo(); //in the future we are going to get out of main sooner while(running){ ps.grabFrame(); bi = ps.getImage(); myWorld.repaint(); } } public void paint(Graphics g) { if (bi != null){ //you shouldn't have to test this but I often do g.drawImage(bi, 0, 0,null); //the null here is a big vestigial, ignore it } } }