我想要能够选择目录,选到文件夹,而不是具体的那个文件。
谁可以告我?

解决方案 »

  1.   

    JFileChooser c=new JFileChooser();
       c.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
       c.showOpenDialog(null);
      

  2.   

    JFileChooser chooser = new JFileChooser();
          chooser.setCurrentDirectory(new File("."));
          
          // accept all files ending with .gif
          chooser.setFileFilter(new
             javax.swing.filechooser.FileFilter()
             {
                public boolean accept(File f)
                {
                   return f.getName().toLowerCase().endsWith(".gif") || f.isDirectory();
                }            public String getDescription() { return "GIF Images"; }
             });