Here you can find the source of chooseFile()
public static File chooseFile()
//package com.java2s; //License from project: Open Source License import java.io.File; import javax.swing.JFileChooser; import javax.swing.JFrame; import javax.swing.filechooser.FileNameExtensionFilter; public class Main { public static File chooseFile() { JFileChooser chooser = new JFileChooser(); File f = null;/*from w ww .j a v a 2 s . c o m*/ FileNameExtensionFilter filter = new FileNameExtensionFilter("Audio Files", "wav", "mp3", "flac"); //chooser.setFileFilter(filter); int returnVal = chooser.showOpenDialog(new JFrame("")); if (returnVal == JFileChooser.APPROVE_OPTION) { f = chooser.getSelectedFile(); System.out.println("You chose to open this file: " + f.getName()); } return f; } }