Results 1 to 5 of 5

Thread: JFileChooser/FileFilter{Resolved}

Threaded View

  1. #1

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Resolved JFileChooser/FileFilter{Resolved}

    Anyone know what i might be doing wrong. I can see that when jfc.showOpenDialog(jf); is called all of the files within the current directory are being scanned cause i can see them flying through the dos window, but when i change the extension in the FileDialog the files that come up within the JFileChooser aren't being filtered.
    Code:
     openfile.addActionListener(new ActionListener(){
       public void actionPerformed(ActionEvent evt){
        class JavaFilter extends javax.swing.filechooser.FileFilter{
          public boolean accept(File file){
           String filename = file.getName(); 
           String extension = filename.substring(0, filename.length());
           System.out.println(extension);
           if(extension.equals(".java")){
            return true;
           }
    	return false; 
           }
           public String getDescription() {
            return ".java Files";
           }
          }
           JFileChooser jfc = new JFileChooser();
           jfc.setFileFilter(new JavaFilter());
           jfc.showOpenDialog(jf);
       }
      });

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width