Hi I made a small music player. But when I select the file the windows does not turn up but the music plays in the background and I get these exceptions
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at Musique.openFile(Musique.java:72)
at Musique.init(Musique.java:37)
at TaskPanel.actionPerformed(TaskPanel.java:43)
at javax.swing.AbstractButton.fireActionPerformed(Abs tractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed (AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed (DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultB uttonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.jav a:6134)
at javax.swing.JComponent.processMouseEvent(JComponen t.java:3265)
at java.awt.Component.processEvent(Component.java:589 9)
at java.awt.Container.processEvent(Container.java:202 3)
at java.awt.Component.dispatchEventImpl(Component.jav a:4501)
at java.awt.Container.dispatchEventImpl(Container.jav a:2081)
at java.awt.Component.dispatchEvent(Component.java:43 31)
at java.awt.LightweightDispatcher.retargetMouseEvent( Container.java:4299)
at java.awt.LightweightDispatcher.processMouseEvent(C ontainer.java:3963)
at java.awt.LightweightDispatcher.dispatchEvent(Conta iner.java:3893)
at java.awt.Container.dispatchEventImpl(Container.jav a:2067)
at java.awt.Window.dispatchEventImpl(Window.java:2458 )
at java.awt.Component.dispatchEvent(Component.java:43 31)
at java.awt.EventQueue.dispatchEvent(EventQueue.java: 599)
at java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:284)
at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:122)
import java.io.*; import java.io.FileInputStream.*; import java.awt.*; import javax.swing.JInternalFrame; import javax.swing.UIManager.*; import javax.swing.event.InternalFrameEvent; import javax.media.*; import com.sun.media.ui.*; import java.net.*; import javax.swing.event.InternalFrameAdapter; class Musique implements ControllerListener { String filename; FileDialog fd; public void init() { core c = new core(); if (fd == null) { fd = new FileDialog(c,"Open File", FileDialog.LOAD); fd.setDirectory("/movies"); } fd.show(); if (fd.getFile() != null) { String filename = fd.getDirectory() + fd.getFile(); openFile("file:" + filename); } } public void openFile(String filename) { //writepadstart w = new writepadstart(); String mediaFile = filename; Player player = null; // URL for our media file URL url = null; try { // Create an url from the file name and the url to the // document containing this applet. if ((url = new URL(mediaFile)) == null) { Fatal("Can't build URL for " + mediaFile); return; } // Create an instance of a player for this media try { player = Manager.createPlayer(url); } catch (NoPlayerException e) { Fatal("Error: " + e); } } catch (MalformedURLException e) { Fatal("Error:" + e); } catch (IOException e) { Fatal("Error:" + e); } if (player != null) { core c = new core(); this.filename = filename; JMFrame1 jmframe = new JMFrame1(player, filename); c.cont.add(jmframe); jmframe.moveToFront(); jmframe.setClosable(true); jmframe.setMaximizable(true); jmframe.setIconifiable(true); jmframe.setResizable(true); jmframe.show(); } } static void Fatal(String s) { MessageBox mb = new MessageBox("JMF Error", s); } public void controllerUpdate(ControllerEvent arg0) { throw new UnsupportedOperationException("Not supported yet."); } } class JMFrame1 extends JInternalFrame implements ControllerListener { Player mplayer; Component visual = null; Component control = null; int videoWidth = 0; int videoHeight = 0; int controlHeight = 30; int insetWidth = 10; int insetHeight = 30; boolean firstTime = true; JMFrame1(Player player, String title) { getContentPane().setLayout( new BorderLayout() ); setSize(320, 10); setLocation(50, 50); setVisible(true); mplayer = player; mplayer.addControllerListener((ControllerListener) this); mplayer.realize(); addInternalFrameListener( new InternalFrameAdapter() { @Override public void internalFrameClosing(InternalFrameEvent ife) { mplayer.close(); } } ); } public void controllerUpdate(ControllerEvent ce) { if (ce instanceof RealizeCompleteEvent) { mplayer.prefetch(); } else if (ce instanceof PrefetchCompleteEvent) { if (visual != null) return; if ((visual = mplayer.getVisualComponent()) != null) { Dimension size = visual.getPreferredSize(); videoWidth = size.width; videoHeight = size.height; getContentPane().add("Center", visual); } else videoWidth = 320; if ((control = mplayer.getControlPanelComponent()) != null) { controlHeight = control.getPreferredSize().height; getContentPane().add("South", control); } setSize(videoWidth + insetWidth, videoHeight + controlHeight + insetHeight); validate(); mplayer.start(); } else if (ce instanceof EndOfMediaEvent) { mplayer.setMediaTime(new Time(0)); mplayer.start(); } } }