-
October 6th, 2013, 01:42 AM
#1
jinternalframe media
I currently made a program where i have an internal frame on a desktop pane. That works fine, but what i'm trying to do is have a media player streaming only on the internal frame not the desktop pane. When i added my media player the desktop pane still shows but the internal frame doesn't and i know that the media is playing because i can hear it, but it the internal frame and the video doesn't display.
Code:
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.JInternalFrame;
import javax.media.*;
public class InternalTest extends JFrame
{
JDesktopPane dp;
Player _player;
public InternalTest()
{
dp = new JDesktopPane();
add(dp);
setContentPane(dp);
setLayout(null);
JButton button3 = new JButton("Hope this Works");
button3.setBounds(500,300,100,100);
dp.add(button3);
/*setLayout(new BorderLayout());
JPanel panel1 = new JPanel();
JPanel panel2 = new JPanel();
JButton button1 = new JButton("North Button");
panel1.add(button1);
add(panel1,BorderLayout.NORTH);
add(panel2,BorderLayout.SOUTH); */
JInternalFrame frame = new JInternalFrame("Preview",
true,
true,
true,
true);
frame.setVisible(true);
frame.setSize(500,500);
frame.setLayout(new BorderLayout());
JButton button1 = new JButton("North Button");
button1.setBounds(0,10,50,50);
frame.add(button1);
frame.add(button1);
JPanel panel = new JPanel();
String mediaFile = "DD.avi";
try{
MediaLocator mlr = new MediaLocator("file:" + mediaFile );
_player = Manager.createRealizedPlayer(mlr);
if ( _player.getControlPanelComponent() !=null)
panel.add("South", _player.getControlPanelComponent());
_player.start();
}
catch (Exception e){
System.err.println("Got exception" + e );
frame.getContentPane().add(panel);
dp.add(frame);
//panel2.add(frame);
addWindowListener( new WindowAdapter(){
public void windowClosing( WindowEvent e)
{
_player.stop();
_player.deallocate();
_player.close();
System.exit(0);
}
});
setLocationRelativeTo(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
setTitle("Hope this works");
this.setExtendedState(Frame.MAXIMIZED_BOTH);
}
}
public static void main(String[] args)
{
InternalTest it = new InternalTest();
it.show();
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|