Wieso krieg ich beim Auslösen das StopButtons ne NullPointerException?
Code:
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javazoom.jl.encoder.*;
import javazoom.jl.decoder.*;
import javazoom.jl.player.*;
import javazoom.jl.advanced.*;
public class mp3plugin extends JFrame implements ActionListener {
FileInputStream in;
AdvancedPlayer p;
JButton
play,
stop;
public mp3plugin() {
JFrame jf = new JFrame("mp3plugin");
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jf.setBounds(150,100,400,300);
Container cp = jf.getContentPane();
cp.setLayout(new FlowLayout());
in = new FileInputStream("demo.mp3");
p = new AdvancedPlayer(in);
play = new JButton("play");
stop = new JButton("stop");
play.addActionListener(this);
stop.addActionListener(this);
cp.add(play);
cp.add(stop);
jf.setVisible(true);
}
public void actionPerformed(ActionEvent aevt) {
if(aevt.getSource()==play) {
playThread.start();
}
if(aevt.getSource()==stop) {
p.stop();
}
}
class playThread implements Runnable {
public void run() {
try{p.play()}catch(Exception x){System.out.println(x.getMessage());}
}
}
public static void main(String[] args) {
new mp3plugin();
}
}