FileFilter for JFileChooser

后端 未结 5 1506
走了就别回头了
走了就别回头了 2020-12-17 15:45

I want to restrict a JFileChooser to select only mp3 files. But, the following code allows all file types:

FileFilter filter = new FileNameExten         


        
5条回答
  •  抹茶落季
    2020-12-17 16:10

    Try:

    FileFilter filter = new FileNameExtensionFilter("My mp3 description", "mp3");
    

    The first argument is simply a description of the FileNameExtensionFilter - and since the second argument is var args, you can leave it out like you did, effectively meaning there is no filter.

提交回复
热议问题