JFileChooser filters
2022-09-02 00:21:04
I am putting a in my program, but that only takes images. So I decided to add filters:JFileChooser
Code
import javax.swing.*;
public class fileChooser {
public static void main(String[] args) {
JPanel panel = new JPanel();
final JFileChooser fc = new JFileChooser();
int file = fc.showOpenDialog(panel);
fc.addChoosableFileFilter(new ImageFilter());
fc.setAcceptAllFileFilterUsed(false);
}
}
I got that straight from the Java tutorials. But Eclipse underlines the following as an error:
fc.addChoosableFileFilter(new ImageFilter());
fc.setAcceptAllFileFilterUsed(false);
Any suggestions?