I want to create a new file while file type is choosing by the user on JFileChooser. How this is possible. I use this code for JFileChooser:
JFileChooser chooser = new JFileChooser();
chooser.setDialogTitle("Save data in your file format");
FileFilter type1 = new ExtensionFilter("Access 2007 Database(*.accdb)", ".accdb");
FileFilter type2 = new ExtensionFilter("Access 2002-2003 Database(*.mdb)", ".mdb");
chooser.addChoosableFileFilter(type1);
chooser.addChoosableFileFilter(type2);
int actionDialog = chooser.showSaveDialog(frame);
Now I an able to get the "File Name" when the user select any file by this code:
chooser.getSelectedFile().getName();
But I dont know how to get "Files of type" when user select any file. For the convenience I also attach photo of JFileChooser:
You can get that information using JFileChooser .getFileFilter()
Returns the currently selected file filter
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.