Results 1 to 6 of 6

Thread: java frame

  1. #1
    jumpman8947 is offline Member
    Join Date
    Feb 2013
    Posts
    38
    Rep Power
    0

    Default java frame

    I currently have a code to display video playback and it works but i want to instead of having it play in its own window i want it to play from in my Jframe. Here's the code thanks...
    Java Code:
    import javax.swing.*;
    import javax.media.*;
    import java.awt.event.*;
    import java.awt.*;
    import java.io.*;
    import java.net.*;
    import javax.swing.text.*;
    import java.net.URL;
    
    public class JPlayer extends JFrame
    {
    	private JPanel mainPanel;
    
    	public JPlayer( URL mediaURL )
    	{
    
    		Manager.setHint( Manager.LIGHTWEIGHT_RENDERER, true );
    
    		try
    		{
    			Player mediaPlayer = Manager.createRealizedPlayer( mediaURL );
    
    			Component video = mediaPlayer.getVisualComponent();
    			Component controls = mediaPlayer.getControlPanelComponent();
    
    			if ( video != null )
    				add( video, BorderLayout.CENTER );
    
    			if ( controls != null)
    				add( controls, BorderLayout.SOUTH );
    
    			mediaPlayer.start();
    		}
    		catch ( NoPlayerException noPlayerException )
    		{
    			System.err.println( "No media player found" );
    		}
    		catch ( CannotRealizeException cannotRealizeException )
    		{
    			System.err.println( "Could not realize media player" );
    		}
    		catch ( IOException iOException )
    		{
    			System.err.println( "Error reading from the source" );
    		}
    
    
    
    		mainPanel = new JPanel();
    		getContentPane().add(mainPanel);
    		mainPanel.setLayout(null);
    		setTitle("Josh Player");
    		setLocationRelativeTo(null);
    		setDefaultCloseOperation(EXIT_ON_CLOSE);
    		setVisible(true);
    		this.setExtendedState(Frame.MAXIMIZED_BOTH);
    	}
    	public static void main(String[] args)
    	{
    		  JFileChooser fileChooser = new JFileChooser();
    
    		          // show open file dialog
    		          int result = fileChooser.showOpenDialog( null );
    
    		          if ( result == JFileChooser.APPROVE_OPTION ) // user chose a file
    		          {
    		             URL mediaURL = null;
    
    		             try
    		             {
    		                // get the file as URL
    		                mediaURL = fileChooser.getSelectedFile().toURL();
    		             } // end try
    		             catch ( MalformedURLException malformedURLException )
    		             {
    		                System.err.println( "Could not create URL for the file" );
    		             } // end catch
    
    		             if ( mediaURL != null ) // only display if there is a valid URL
    		             {
    		                JFrame mediaTest = new JFrame( "Media Tester" );
    		                mediaTest.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    
    		                MediaPanel mediaPanel = new MediaPanel( mediaURL );
    		                mediaTest.add( mainPanel );
    
    		               // mediaTest.setSize( 300, 300 );
                    //mediaTest.setVisible( true );
    			}
    		}
    
    
    
    
    
    
    
    		//JPlayer jp = new JPlayer();
    		//MediaPanel mediaPanel = new MediaPanel( mediaURL );
    		//mainPanel.add( mediaPanel );
    
    	}
    
    }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: java frame

    You haven't bothered to return to 5 of the threads you started. How do we know whether you're really interested in an answer in this one?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    jumpman8947 is offline Member
    Join Date
    Feb 2013
    Posts
    38
    Rep Power
    0

    Default Re: java frame

    all my other threads the solution has been found, or there have been no replies to the thread.

  4. #4
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    United States
    Posts
    3,384
    Rep Power
    5

    Default Re: java frame

    If a solution is found by you then post it so others may benefit. If someone else helps you find a solution then thanking them is always a good thing. It also keeps others from wasting their time providing you answers or help when none is needed.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  5. #5
    jumpman8947 is offline Member
    Join Date
    Feb 2013
    Posts
    38
    Rep Power
    0

    Default Re: java frame

    Thanks, no problem will do.

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default Re: java frame

    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Replies: 6
    Last Post: 04-12-2013, 06:33 AM
  2. Replies: 7
    Last Post: 04-01-2012, 04:11 AM
  3. Replies: 4
    Last Post: 01-18-2011, 08:22 AM
  4. Java slave Frame access to its owner main frame problem
    By cagdaseckin in forum New To Java
    Replies: 0
    Last Post: 12-10-2010, 10:40 AM
  5. Replies: 7
    Last Post: 11-02-2009, 06:31 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •