This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
i am still working on this but many thanks to Rob. i now have a menu with open and save as MenuItems.i use a FileChooser to display the open and save dialogs. the open works fine and im sure the save will be easy also. but i am wondering about exceptions, in particular IllegalArgumentException which ImageIO claims to throw. i tried to use the following code to open a .txt file and got no exception. it didnt display the file either.
i noticed the dialogs had choice of "all files" only. i imagine there is a way to restrict file extensions, but handling the IllegalArgumentException seems easier.
i will probably check that out just to learn. i figured out what i was doing wrong though. ImageIO throw the IllegalArgument exception if the input is null. if the file is one it cant read the it RETURNS null. so instead of catching an exception i had to see if the BufferedImage was null.
this is kind of off the topic, but now i am having a problem with JOptionPane. another program i wrote had this line which works fine:
JOptionPane.showMessageDialog( mainWindow,"Example program", "About this Program", JOptionPane.PLAIN_MESSAGE );
now i am trying this which displays a blank modal dialog with title Error which i cant close
String message = "This program can only open image files, like gif or jpg";
JOptionPane.showMessageDialog( this, message, "Error", JOptionPane.ERROR_MESSAGE );
i dont see what i am doing different to cause this