@Action(enabledProperty = "fileOpenEnabled", selectedProperty = "fileOpenSelected")
public void fileOpen() {
File file = null;
FileImageInputStream inputStream = null;
BufferedImage bi = null;
Logger logger = Logger.getLogger(ImageToolsView.class.getName());
// Present the "open" file chooser without any file selected.
// If the user cancels this file chooser, exit this method.
imageChooser.setSelectedFile(null);
if (imageChooser.showOpenDialog(mainFrame) !=
JFileChooser.APPROVE_OPTION) {
return;
}
// Obtain the selected file. Validate its extension, which
// must be .jpg or .jpeg. If extension not present, append
// .jpg extension.
file = imageChooser.getSelectedFile();
// check if file exists and make sure it's an image(or .jpg)
// if not show an error box
if (file.exists()) {
// open it
try {
inputStream = new FileImageInputStream(file);
} catch (FileNotFoundException ex) {
logger.log(Level.SEVERE, null, ex);
showError("File not found " + ex);
} catch (IOException ex) {
logger.log(Level.SEVERE, null, ex);