JFileChooser select directory but show files

后端 未结 9 1776
孤城傲影
孤城傲影 2020-12-11 00:49

I feel like there should be a simple way to do this but I can\'t figure it out. I have a JFileChooser that allows the user to select directories. I want to show all the file

9条回答
  •  醉酒成梦
    2020-12-11 01:28

    Keep the fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY) and use:

    File[] selectedFiles = fileChooser.getSelectedFile().listFiles();
    

提交回复
热议问题