Problems during outputing Jpanel

I got how to add gif images to the panel,but when i try to display them, it just only shows the window (similar to a minimized window),but not the images. I don't know whyMessage was edited by: Arcanine
[245 byte] By [Arcaninea] at [2007-10-3 6:02:57]
# 1

import java.awt.*;

import java.awt.image.BufferedImage;

import java.io.*;

import javax.imageio.ImageIO;

import javax.swing.*;

public class ImageGrid {

private JPanel getContent(BufferedImage image) {

JPanel panel = new JPanel(new GridLayout(0,3));

ImageIcon icon = new ImageIcon(image);

for(int j = 0; j < 9; j++) {

panel.add(new JLabel(icon));

}

return panel;

}

public static void main(String[] args) throws IOException {

// image is in the images folder which is in the

// current directory

String path = "images/Rabbit.gif";

BufferedImage image = ImageIO.read(new File(path));

JFrame f = new JFrame();

f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

f.getContentPane().add(new ImageGrid().getContent(image));

f.pack();

f.setLocation(200,200);

f.setVisible(true);

}

}

74philipa at 2007-7-15 0:45:15 > top of Java-index,Desktop,Core GUI APIs...
# 2

> I don't know why

Neither do we, since we are not mind readers and you demo code is not posted.

If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program[/url] (SSCCE) that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.

And don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags[/url] so the code retains its original formatting.

camickra at 2007-7-15 0:45:15 > top of Java-index,Desktop,Core GUI APIs...