Re: simple help about JFileChooser
<dreamtackler@gmail.com> wrote in message
news:8726ee8a-4697-4a43-b7f2-6067c3e5c233@q24g2000prf.googlegroups.com...
public void aaa(){
JFileChooser chooser=new JFileChooser();
chooser.setFileFilter(new FileFilter() {
public boolean accept(File f) {
String fileName = f.getName().toLowerCase();
return fileName.endsWith(".txt") || f.isDirectory();
}
public String getDescription() {
return "Text Files";
}
});
chooser.showOpenDialog(this);
}
oh,god ,i am sure there is no mistake in my mthhod on case sensitive.
i just copy it from a class to another class .and it go wrong and the
IDE
said that in javax.swing.JFileChooser can't applied to (<anonymous
| java.io.fileFilter>).
As you probably know by now there are two types named FileFilter. One is
the interface java.io.FileFilter and the other is
javax.swing.filechooser.FileFilter. When you pasted your code, the IDE
chose to resolve FileFilter in your 3rd line as java.io.FileFilter rather
than javax.swing.filechooser.FileFilter, so your anonymous class is
technically the wrong type. Make the IDE forget its choice and choose again
or simply put the fully qualified class name in.
Matt Humphrey http://www.iviz.com/