Hello! Made a simple window containing one button. She opens the dialogue. Each time you press, another line appears in the "File Type" list. Tell me please, what's the problem?
//ImageFilter1.java public class ImageFilter1 extends FileFilter { private String description; private String[] extensions=null; private String extension=null; //... public String getDescription(){ return description; } } //JChooserTest public class JChooserTest{ //..... JFileChooser choose = new JFileChooser(); show.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String[] exts = new String[]{".png",".jpg"}; choose.setFileFilter(new ImageFilter1("Images: *.png *.jpg", exts)); int returnVal = choose.showDialog(frame, "Attach"); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = choose.getSelectedFile(); System.out.println("Opening: " + file.getName() + "."); } else { System.out.println("Open command cancelled by user."); } } }); //..... } }