2 Replies - 191 Views - Last Post: 06 October 2013 - 10:09 AM Rate Topic: -----

#1 jumpman8947  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 03-February 13

internal frame display

Posted 05 October 2013 - 11:41 PM

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.
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();
}


}



Is This A Good Question/Topic? 0
  • +

Replies To: internal frame display

#2 manofax  Icon User is offline

  • New D.I.C Head

Reputation: 12
  • View blog
  • Posts: 20
  • Joined: 17-May 13

Re: internal frame display

Posted 06 October 2013 - 01:42 AM

Having just had a brief read through of your code, I've noticed that you call frame.setVisible(true) BEFORE you have added all your components to it. This causes the frame to display only the content that has been added to it BEFORE the .setVisible(true) call...Try calling the .setVisible(true) call after you have added all your content to the frame and see if this fixes your problem...
Was This Post Helpful? 0
  • +
  • -

#3 jumpman8947  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 03-February 13

Re: internal frame display

Posted 06 October 2013 - 10:09 AM

I moved frame.setVisible after line 60 dp.add(frame) and i'm getting the same problem
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1