Package COM. test; import javax. swing. jfilechooser; import javax. swing. uimanager; import javax. swing. unsupportedlookandfeelexception; import javax. swing. filechooser. filenameextensionfilter;/*** use jfilechooser * @ author administrator **/public class jfilechoosertest {public static void main (string [] ARGs) throws classnotfoundexception, instantiationexception, illegalaccessexception, unsupportedlookandfeelexception {string Path = NULL; // set the UI style uimanager. setlookandfeel (uimanager. getsystemlookandfeelclassname (); jfilechooser jdir = new jfilechooser (); // you can specify the path mode jdir. setfileselectionmode (jfilechooser. files_only); // filter file type filenameextensionfilter filter = new filenameextensionfilter ("Excel file (*. XLS ;*. XLSX;) "," xls "," XLSX "); jdir. setfilefilter (filter); // set the title of the dialog box jdir. setdialogtitle ("select the file path"); If (jfilechooser. approve_option = jdir. showopendialog (null) {// The user clicked OK Path = jdir. getselectedfile (). getabsolutepath (); // select the obtained path} system. out. println (PATH );}}