use of gmgen.gui.ImageFileChooserPreview in project pcgen by PCGen.
the class NotesView method getImageFromChooser.
/**
* obtains an Image for input using a custom JFileChooser dialog
*
*@param startDir Directory to open JFielChooser to
*@param exts Extensions to search for
*@param desc Description for files
*@return File pointing to the selected image
*/
private File getImageFromChooser(String startDir, String[] exts, String desc) {
JFileChooser jImageDialog = new JFileChooser();
jImageDialog.setCurrentDirectory(new File(startDir));
jImageDialog.setAccessory(new ImageFileChooserPreview(jImageDialog));
jImageDialog.setDialogType(JFileChooser.CUSTOM_DIALOG);
jImageDialog.setFileFilter(new FileNameExtensionFilter(desc, exts));
jImageDialog.setDialogTitle("Select an Image to Insert");
int optionSelected = jImageDialog.showDialog(this, "Insert");
if (optionSelected == JFileChooser.APPROVE_OPTION) {
return jImageDialog.getSelectedFile();
}
return null;
}
Aggregations