JFileChooser 的 FileFilter 有编译错误

FileFilter for JFileChooser has compilation errors

Eclipse 显示两个错误:

JFileChooser chooser = new JFileChooser();
FileFilter filter = new FileNameExtensionFilter("PDF Documents", "pdf");
chooser.addChoosableFileFilter(filter);

解决方案是导入 javax.swing.filechooser.FileFilter 而不是 java.io.FileFilter