小智 10
用途FileChooser:
JFileChooser fc = new JFileChooser();
int returnVal = fc.showOpenDialog(frame); //Where frame is the parent component
File file = null;
if (returnVal == JFileChooser.APPROVE_OPTION) {
file = fc.getSelectedFile();
//Now you have your file to do whatever you want to do
} else {
//User did not choose a valid file
}
Run Code Online (Sandbox Code Playgroud)