D
Darren
When i call the below i get the abover error message
fc.addChoosableFileFilter(new zipfilter());
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int returnVal = fc.showOpenDialog(frame);
as i see it the parameter should be a class inhereted from FileFilter. This
is what i did. I copied the example from Sun's own site and modified but i
get errors when i try to use it as a filter. zipfilter is declared below.
Why am I getting errors?
Thanks
// zipfile.java
import java.io.File;
import javax.swing.*;
import javax.swing.filechooser.*;
/* ImageFilter.java is a 1.4 example used by FileChooserDemo2.java. */
public class zipfilter extends FileFilter {
//Accept all directories and all gif, jpg, tiff, or png files.
public boolean accept(File f)
{
if (f.isDirectory())
{
return true;
}
String extension = Utils.getExtension(f);
if (extension != null) {
if (extension.equals(Utils.zip) ||
extension.equals(Utils.jar))
{
return true;
}
else
{
return false;
}
}
return false;
}
//The description of this filter
public String getDescription()
{
return "Archives";
}
}
fc.addChoosableFileFilter(new zipfilter());
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int returnVal = fc.showOpenDialog(frame);
as i see it the parameter should be a class inhereted from FileFilter. This
is what i did. I copied the example from Sun's own site and modified but i
get errors when i try to use it as a filter. zipfilter is declared below.
Why am I getting errors?
Thanks
// zipfile.java
import java.io.File;
import javax.swing.*;
import javax.swing.filechooser.*;
/* ImageFilter.java is a 1.4 example used by FileChooserDemo2.java. */
public class zipfilter extends FileFilter {
//Accept all directories and all gif, jpg, tiff, or png files.
public boolean accept(File f)
{
if (f.isDirectory())
{
return true;
}
String extension = Utils.getExtension(f);
if (extension != null) {
if (extension.equals(Utils.zip) ||
extension.equals(Utils.jar))
{
return true;
}
else
{
return false;
}
}
return false;
}
//The description of this filter
public String getDescription()
{
return "Archives";
}
}