/** * Play the sound file currently selected in the file list. If there is no selection in the list, * or if the selected file is not a sound file, do nothing. */ private void play() { String filename = (String) fileList.getSelectedValue(); if (filename == null) { // nothing selected return; } // slider.setValue(0); boolean successful = player.play(new File(AUDIO_DIR, filename)); if (successful) { showInfo(filename + " (" + player.getDuration() + " seconds)"); } else { showInfo("Could not play file - unknown format"); } }