Here you can find the source of openImage()
public static BufferedImage openImage()
//package com.java2s; //License from project: Open Source License import javax.imageio.ImageIO; import javax.swing.*; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; public class Main { public static BufferedImage openImage() { BufferedImage image = null; File file;//from w ww. ja v a 2 s . c om JFileChooser fC = new JFileChooser(new File(".")); if (JFileChooser.APPROVE_OPTION == fC.showOpenDialog(null)) { file = fC.getSelectedFile(); try { image = ImageIO.read(file); } catch (IOException e) { } } return image; } }