/ Published in: Java
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
package org.jmf.example; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import javax.swing.plaf.metal.MetalLookAndFeel; public class ExampleJMF { { try { } { e.printStackTrace(); } new exampleFrame(); } } package org.jmf.example; import java.awt.Toolkit; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import javax.swing.JFrame; { private static final long serialVersionUID = 1L; public exampleFrame() { super("JMF - Example..."); setSize(400, 300); { { } }); setContentPane(new examplePanel()); setVisible(true); } } package org.jmf.example; import java.awt.Component; import java.awt.Graphics; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import javax.media.ControllerEvent; import javax.media.ControllerListener; import javax.media.Manager; import javax.media.NoPlayerException; import javax.media.Player; import javax.media.RealizeCompleteEvent; import javax.swing.JPanel; { private static final long serialVersionUID = 1L; private Player player; public examplePanel() { try { player.addControllerListener(this); player.start(); } catch(NoPlayerException e) { e.printStackTrace(); } { e.printStackTrace(); } { e.printStackTrace(); } } { super.paintComponent(g); } { } public void controllerUpdate(ControllerEvent c) { if(player == null) return; if(c instanceof RealizeCompleteEvent) { if((visualComponent = player.getVisualComponent()) != null) add(visualComponent); } } }