class Myfilter extends javax.swing.filechooser.FileFilter
{
public boolean accept(File file)
{
String filename = file.getName();
return filename.endsWith(".xml");
}
public String getDescription()
{
return "*.xml";
}
}
Asked
Active
Viewed 45 times
-1

AJ.
- 4,526
- 5
- 29
- 41

manujindal
- 11
- 2
-
1`myJFileChooser.setFileFilter(new Myfilter())`? – Alexis C. Jan 15 '14 at 11:59
2 Answers
1
By calling the setFileFilter
method.
E.g., in your code:
JFileChooser chooser = new JFileChooser();
chooser.setFileFilter(new Myfilter());
1
calling set filter may not work here , I got the better solution by below code
FileNameExtensionFilter("XML","xml","xml&XML"));

Sumit Pathak
- 671
- 1
- 6
- 25

manujindal
- 11
- 2