Dialog box classes for database files.
Example of use of DatabaseFileChooser:
private DatabaseFile getFile() {
// Initialise dialog.
DatabaseFileChooser fc = new DatabaseFileChooser();
// Remove AcceptAll file filter.
fc.removeChoosableFileFilter(fc.getAcceptAllFileFilter());
// Add database file filter.
fc.addChoosableFileFilter(new ClustalFileFilter());
// Set title.
fc.setDialogTitle("Open Clustal file");
try {
// Open file selected by user.
if (fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
return fc.getSelectedDatabaseFile();
}
}
catch(FileTypeException fte) {
JOptionPane.showMessageDialog(
this,
"Cannot open file - has an unrecognised suffix",
"File suffix error",
JOptionPane.ERROR_MESSAGE
);
}
return null;
} // End of method.