I have written a class to pull an image(s) from my HDD by pathname and I want to use the BufferImage class to read the image and then use the Graphics class from .AWT to drawImage onto the contentPane of my Frame. I have set up the drawImage in a for loop because I want to reproduce the image 5 times onto different areas using absolute position but the method is giving me a blank container. Any help? Here are the two classes

Main class:
public class Main{

    BufferedImage card;

    public static void main (String[] args){
        Main test = new Main();

    public void start(){
        DisplayCards dc = new DisplayCards();
        card = dc.findCard();

Display class:

 public BufferedImage findCard(){
        try {
            System.out.println("Enter filepath\n");
            BufferedReader bf = new BufferedReader
                    (new InputStreamReader(System.in));
            String imageName = bf.readLine();
            File inputFile = new File(imageName);
            tempImage = ImageIO.read(inputFile);
        } catch (IOException ie) {
            System.out.println("Error:" + ie.getMessage());
        return tempImage;

    public void paintCard(BufferedImage image){
        JFrame frame = new JFrame("Card Game");
        Panel panel = new DisplayCards();
        Graphics g;
        g = frame.getContentPane().getGraphics();
        g.drawImage(image, 100, 100, null);

       for (int i=0; i<5; i++){
        g.drawImage(image, (i * 150 + 25), 50, null);

Last edited by shabbir; 26May2011 at 08:43.. Reason: Code blocks