JFileChooser chooser = new JFileChooser(); chooser.setApproveButtonText("確定"); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); //設置只選擇目錄
int returnVal = chooser.showOpenDialog(SwingWorkerUI.this); System.out.println("returnVal="+returnVal); if (returnVal == JFileChooser.APPROVE_OPTION) { System.out.println("You chose to open this file: "+ chooser.getSelectedFile().getName());