open.setDialogType(isOpen ? JFileChooser.OPEN_DIALOG : JFileChooser.SAVE_DIALOG);
if (ext.length()>0) open.setFileFilter(new FileFilter() {
public boolean accept(File file) { return !file.isFile() || file.getPath().toLowerCase(Locale.US).endsWith(ext); }
public String getDescription() { return description; }
});
if (open.showDialog(null, null) != JFileChooser.APPROVE_OPTION || open.getSelectedFile() == null) return null;
ans = open.getSelectedFile().getPath();
} catch(Exception ex) {
// Some combination of Windows version and JDK version will trigger this failure.
// In such a case, we'll fall back to using the "AWT" file open dialog
useAWT = true;