Playing an audio file on JButton press?
I've looked on Google for a while, searching how to play audio files, and most of the sources I found were with using java.applet.* , but I am trying to look for a way I can put it inside my actionPerformed() method. public void actionPerformed(ActionEvent event) { if(event.getActionCommand().equals("Play")){ //Short Audio File Playing Here } } Andrew Thompson See the JavaSound info. page for the "Playing a Clip" section. You may learn and use javax.sound API. Have a look at tutorial - Playing Back Audio . 来源: https://stackoverflow.com/questions/8997363/playing-an-audio-file-on-jbutton-press