1 19 20 package de.gulden.util.swing; 21 22 import java.io.File ; 23 import java.util.*; 24 import javax.swing.filechooser.FileFilter ; 25 26 32 public class SuffixFileFilter extends FileFilter { 33 34 38 41 protected String suffix; 42 43 46 protected String description; 47 48 49 53 56 public SuffixFileFilter() { 57 super(); 58 } 59 60 63 public SuffixFileFilter(String suffix, String description) { 64 this(); 65 this.suffix=suffix; 66 this.description=description; 67 } 68 69 70 74 77 public String getSuffix() { 78 return suffix; 79 } 80 81 84 public void setSuffix(String _suffix) { 85 suffix = _suffix; 86 } 87 88 91 public String getDescription() { 92 return "*."+getSuffix()+" - "+description; 93 } 94 95 98 public void setDescription(String _description) { 99 description = _description; 100 } 101 102 public boolean accept(File file) { 103 if (file.isDirectory()) { return true; 105 } 106 String suffix=getSuffix(); 107 if ((suffix==null)||suffix.equals("")||suffix.equals("*")) { 108 return true; 109 } else { 110 String f=file.getName(); 111 return f.endsWith("."+suffix); 112 } 113 } 114 115 } | Popular Tags |