tags:

views:

38

answers:

1

Hi, i'm using swings jfilechooser in program,i want it to filter files with .txt extension,and it is showing allfiles option also in window,so i want to remove allfiles option,how can i do it plz help me

this is my code: fc1 = new JFileChooser();

 fc1.setMultiSelectionEnabled(true); // Allow for multiple selections
 fc1.setCurrentDirectory(new File("C:\\"));

fc1.setFileFilter(new FileFilter() { public boolean accept(File f) { return f.getName().toLowerCase().endsWith(".fls") || f.isDirectory(); }

  public String getDescription() {
   // TODO Auto-generated method stub
   return "*.fls";
  }
 });

Thanks in adavance

mukta

+2  A: 

Well, just by reading the javadoc, I can see that there's a method called setAcceptAllFileFilterUsed(boolean). Did you try that? It sounds like it's doing what you want.

aberrant80
ya its working thanks
Could you mark your question as answered?
aberrant80