我在我的程序中放置了一个JFileChooser,但是只能使用图像.所以我决定添加过滤器:
码
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);
}
}
我从Java教程中直截了当.但Eclipse强调以下错误:
fc.addChoosableFileFilter(new ImageFilter());
fc.setAcceptAllFileFilterUsed(false);
有什么建议么?