当按下按钮时,我试图让这个声音停止。下面是我的播放功能。我已经设置好了按钮,我只需要给它做点什么……谢谢!
void play() {
try {
URL url2 = this.getClass().getClassLoader().getResource("tone.wav");
AudioInputStream audioIn = AudioSystem.getAudioInputStream(url2);
Clip clip = AudioSystem.getClip();
clip.open(audioIn);
clip.loop(Clip.LOOP_CONTINUOUSLY);
}catch (UnsupportedAudioFileException e){
e.printStackTrace();
}catch (IOException e) {
e.printStackTrace();
} catch(LineUnavailableException e) {
e.printStackTrace();
}finally{}}