- First of all create a subclass of FileFilter as follows:
- Following subclass of FileFilter will allow the JFileChooser to show only gif files or folders.
public
class GifFilter
extends FileFilter{
public boolean accept(File f){
return f.getName().toLowerCase().endsWith(".gif")
|| f.isDirectory();
}
public String getDescription(){
return "GIF Image";}
}
Once we have a file filter object, we can use the setFileFilter() method of the JFileChooser class to install it into the JFileChooser object.
fileChooser.setFileFilter(new GifFilter());
I have read your blog its very attractive and impressive. I like it your blog.
ReplyDeleteJava Training in Chennai Java Training in Chennai | Core Java Training in Chennai | Java Training Institutes
Online Java Training Java Online Training | Java J2EE Online Training | JavaEE Training Institute in Chennai