#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    23
    Rep Power
    0

    JInternalFrame display


    I have created a frame in which there is an internal jframe showing inside it. What i want to do is use the JMF video playback displaying in the internal frame not the main frame. Currently when i run the program the video plays over the whole frame. all i want it to do is play within the internalJFrame. And with me testing out the code before i added video both frames display so i know that showing both frames isn't the problem. the problem is showing the video inside the internal frame.
    Code:
    import javax.media.*;
    import javax.swing.*;
    import java.awt.*;
    import java.net.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    import java.io.File;
    import java.net.MalformedURLException;
    import java.net.URL;
    
    public class Internal extends JFrame
    {
    	private JPanel mainPanel;
    	Player _player;
    	JFileChooser fileChooser;
    
    	public Internal()
    	{
    
    		mainPanel = new JPanel();
    		getContentPane().add(mainPanel);
    		mainPanel.setLayout(null);
    
    		addWindowListener( new WindowAdapter(){
    			public void windowClosing( WindowEvent e)
    			{
    				_player.stop();
    				_player.deallocate();
    				_player.close();
    				System.exit(0);
    			}
    		});
    
    
    
    
    
    		JInternalFrame f1 = new JInternalFrame("Preview",
    												true,
    												true,
    												true,
    												true);
    		f1.setBounds(810,20,500,370);
    
    		JPanel panel =(JPanel)getContentPane();
    		panel.setLayout(new BorderLayout());
    		String mediaFile = "DD.avi";
    		try{
    			MediaLocator mlr = new MediaLocator("file:" + mediaFile );
    			_player = Manager.createRealizedPlayer(mlr);
    			if (_player.getVisualComponent() !=null)
    			panel.add("Center", _player.getVisualComponent());
    			if(_player.getControlPanelComponent() !=null)
    			panel.add("South", _player.getControlPanelComponent());
    			_player.start();
    		}
    		catch (Exception e) {
    			System.err.println("Got exception" + e );
    
    		//getContentPane().add(panel);
    
    		f1.getContentPane().add(panel);
    
    		mainPanel.add(f1);
    		f1.setVisible(true);
    
    		setTitle("Internal Demo");
    		setLocationRelativeTo(null);
    		setDefaultCloseOperation(EXIT_ON_CLOSE);
    		setVisible(true);
    		this.setExtendedState(Frame.MAXIMIZED_BOTH);
    	}
    }
    	public static void main(String[] args)
    	{
    		Internal in = new Internal();
    		in.show();
    	}
    
    }
  2. #2
  3. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,711
    Rep Power
    347

IMN logo majestic logo threadwatch logo seochat tools logo