I found the way. Just add a LineListener and everything works fine... :D
public void playmusic(){
try{
btnClose.setEnabled(true);
btnShuffle.setEnabled(true);
btnRepeat.setEnabled(true);
btnPause.setEnabled(true);
btnStop.setEnabled(true);
LineListener listener = new LineListener() {
public void update(LineEvent event) {
if (event.getType() == LineEvent.Type.STOP) {
btnPlay.setEnabled(true);
}
}
};
if(isPausing==false){
AudioInputStream ais = AudioSystem.getAudioInputStream(f);
clip = AudioSystem.getClip();
clip.open(ais);
clip.start();
}
else{
isPausing=false;
clip.start();
}
clip.addLineListener(listener);
}
catch(Exception ex){}
}