JFileChooser过滤器

       JFileChooser fd = new JFileChooser();  

       //用内部匿名类自定义过滤器,只看见txt文件       

      fd.setFileFilter(new FileFilter() {

            @Override            

               public boolean accept(File f) {                

                          if (f.isDirectory()) {                    

                                  return true;

                                 }               

                 return f.getName().endsWith(".txt");         

                }

            @Override          

             public String getDescription() {    

             return ".txt";

            }      

   });

posted @ 2014-04-19 19:22  lxm9304  阅读(182)  评论(0)    收藏  举报