import java.io.File; import javax.swing.*; import javax.swing.filechooser.*; public class ImageFileView extends FileView { ImageIcon jpgIcon = new ImageIcon("images/jpgIcon.gif"); ImageIcon gifIcon = new ImageIcon("images/gifIcon.gif"); ImageIcon tiffIcon = new ImageIcon("images/tiffIcon.gif"); public String getName(File f) { return null; // let the L&F FileView figure this out } public String getDescription(File f) { return null; // let the L&F FileView figure this out } public Boolean isTraversable(File f) { return null; // let the L&F FileView figure this out } public String getTypeDescription(File f) { String ext = Utils.getExtension(f); String type = null; if (ext != null) { if (ext.equals(Utils.JPEG_EXT) || ext.equals(Utils.JPG_EXT)) { type = "JPEG Image"; } else if (ext.equals(Utils.GIF_EXT)){ type = "GIF Image"; } else if (ext.equals(Utils.TIFF_EXT) || ext.equals(Utils.TIF_EXT)) { type = "TIFF Image"; } } return type; } public Icon getIcon(File f) { String ext = Utils.getExtension(f); Icon icon = null; if (ext != null) { if (ext.equals(Utils.JPEG_EXT) || ext.equals(Utils.JPG_EXT)) { icon = jpgIcon; } else if (ext.equals(Utils.GIF_EXT)) { icon = gifIcon; } else if (ext.equals(Utils.TIFF_EXT) || ext.equals(Utils.TIF_EXT)) { icon = tiffIcon; } } return icon; } }