JFileChooser filters

后端 未结 6 1621
悲&欢浪女
悲&欢浪女 2020-11-29 08:14

I am putting a JFileChooser in my program, but that only takes images. So I decided to add filters:

Code

import javax.swing.*;

public c         


        
6条回答
  •  不知归路
    2020-11-29 08:54

    the argument of fc.addChoosableFileFilter() should be a subclass of javax.swing.filechooser.FileFilter. For example, you can change your code as

    fc.addChoosableFileFilter(new FileNameExtensionFilter("Image Files", "jpg", "png", "tif");
    

提交回复
热议问题