i dont get this at all. i have used JOptionPane in the past with no problem. here is the relevant code
if the file is an image file it opens it. but if it is not it displays a blank modal dialog with the title Error, but no message and no ok button so i cant close it. i have checked the API and the tutorial but they both say i am doing it correctly
it also throws exceptions the one at the top says:
exception in thread "AWT-EventQueue-0" java.lang.NullPointerEception
i tried replaceing the parameter message with the string literal with the same result. it didnt throw an exception at first and i managed to get it to close using the X in the title bar(which it should'nt do). i kept toying with it and the next time it did throw the exception. it says it is in paintComponent() line 75. im not using an IDE so im not sure but it has to be the line that opens the JDialog. what can possibly be null??? not parent since it displays the image file. not the String. so what is going on???
Michael is right. getGraphics() is an evil method that should never be used. He's also right about not displaying any dialogs from the painting methods. You should initialize the image from somewhere (a button press, constructor, etc), then call repaint(). Your overridden paintComponent method should then draw the image if it's not null.