/** * Opens a file and displays the image. This method is used by main and open item. * * @param filename the file to be opened */ private static void openImageFile(String filename) { // Delegate the problem of reading the filename to another method! BufferedImage img = ImageUtilities.loadImage(filename); if (img == null) { JOptionPane.showMessageDialog(null, filename + " could not be opened."); } else openImage(img, filename); // create the window with a title - see // below }