Hello, ok I have a problem with JFileChooser.When I save a file with a name that exists already, It replaces the older file and saves the new one but I want make it show a confirmation message to the user to ask if they want to replace the file or not. Another problem is that I am using both open and save dialog boxes from JFileChooser to open and save ONLY '.xls' i.e excel files. I have created a fileFilter for this purpose which works well with the open dialog box but when saving a file, I want to force the '.xls' extension to be appended with the file name so I can save ONLY '.xls' files. What it does right now is that it saves the file without an extension which I can later on open with Microsoft Excel using 'Open with..' option and it works fine. But I want to make it an excel file at the time it is saved, Please help.
Here is my fileFilter:
javax.swing.filechooser.FileFilter ff=new javax.swing.filechooser.FileFilter() {
public boolean accept(File f) {
return f.getName().toLowerCase().endsWith(".xls")
|| f.isDirectory();
}
public String getDescription() {
return "Excel Files";
}
};