File/Folder Chooser 选择

 private
 static
 String

 ChooseFolder(
)

{
JFileChooser fc = new JFileChooser ( ) ;
JList list = new JList ( ) ;
fc.setFileSelectionMode ( JFileChooser .DIRECTORIES_ONLY ) ;
if ( JFileChooser .APPROVE_OPTION == fc.showOpenDialog ( list) )
{
File file = fc.getSelectedFile ( ) ;
return file.getPath ( ) ;
}
return "" ;
}
 
private static String ChooseFile( )
{
JFileChooser fc = new JFileChooser ( ) ;
JList list = new JList ( ) ;
fc.setFileSelectionMode ( JFileChooser .FILES_ONLY ) ;
if ( JFileChooser .APPROVE_OPTION == fc.showOpenDialog ( list) )
{
File file = fc.getSelectedFile ( ) ;
return file.getPath ( ) ;
}
return "" ;
}

你可能感兴趣的:(list,String,File)