Hi!
I need help in using JFileChooser.
1.
I want to set the file type so that when the users want to open a file, they can only see <.dat> file.
This is my code:
JFileChooser fc = new JFileChooser();
fc.addChoosableFileFilter(new MyFilter());
fc.setAcceptAllFileFilterUsed(false);
class MyFilter extends javax.swing.filechooser.FileFilter
{
public boolean accept(File file)
{
return file.getAbsolutePath().endsWith (".dat");
}
public
String getDescription() {
return "*.dat";
}
}
Problem: file type column has been set in the dialog box, but file chooser can't browse the folder(can't go inside directory and show the desired file).
2.
how to set the save dialog so that user only need to write file name but it is saved by adding the extension also.e.g fileName.dat
Thanks