final JFrame f = new JFrame("MoviePlayer");
f.addNotify( );
f.setLocation(100, 100);
f.addWindowListener(new WindowAdapter( ) {
public void windowClosing(WindowEvent we) { System.exit(0); }
});
URL url = new URL(args[0]);
final Player player = Manager.createPlayer(url);
player.realize( );
player.addControllerListener(new ControllerListener( ) {
public void controllerUpdate(ControllerEvent ce) {
if (ce instanceof RealizeCompleteEvent) {
Component c = player.getVisualComponent( );
Container content = f.getContentPane( );
content.setLayout(new BorderLayout( ));
content.add(c, BorderLayout.CENTER);
Insets i = f.getInsets( );
Dimension d = c.getSize( );
f.setSize(d.width + i.left + i.right,
d.height + i.top + i.bottom);
f.setVisible(true);
player.start( );
}
}
});