有个媒体播放类
public class AlphaPlayer extends JFrame implements
ControllerListener, ItemListener ,Runnable{
public AlphaPlayer(String strFilePath){ player = Manager.createPlayer(new MediaLocator("file:" + strFilePath));

tRunThread = new Thread(this);
tRunThread.start();
this.setVisible(false);
         .......
         .....
}
public boolean stopPlay(){
player.stop();
this.dispose();

return true;
}
我写了另外一个类调用它的实例
public class PlayMedia {    public void playmedia(int intFileKind) throws Exception{
         apPlayer = new AlphaPlayer(strFileName2);
         .....
         .....}
    public void stopPlay(){
player.stop();
this.dispose();

return ;
                   } 如果我这么调用就有问题,会抛出NULL异常,请问是为什么呢?谢谢
    public static void main(String[] args){
        PlayMedia tPlayer = new PlayMedia("F:/1.mp3");        tPlayer.stopPlay();
            return;
      
    }

解决方案 »

  1.   

    public void playmedia(int intFileKind) throws Exception{
             apPlayer = new AlphaPlayer(strFileName2);
             .....
             .....}
    这个是你的构造函数吗,怎么会有void, 就算你是笔误,那么参数为int,那么你在main中创建PlayMedia时,给的是"f:/1.mp3" 字符串怎么能用?
    你抛出的NUllPoiniter 在什么位置,可以贴出来看看