Reputation: 1
I made a image lists like this in java:
static String[] imageList1 = { "images/bgs/bg.png", "images/bgs/image1.png",
"images/bgs/image2.png", "images/bgs/image3.png" };
I use the image in the image list as a background like this:
JLabel background = new JLabel(new ImageIcon(imageList1[0]));
The problem is when I run the program the whole frame was blank(supposedly the frame consists from only one picture image
and one button
) but if I minimize and then maximize or adjust the width or height of the frame, it suddenly shows the image
and the button
.
Upvotes: 0
Views: 59
Reputation: 3203
Have you tried calling revalidate(); repaint();
?
That might fix your issue, but what you are looking for is the JImagePanel class. It is a third-party util and should make your life much easier. Get the source here.
Then, just add this panel to the root of the JFrame and viola!
Upvotes: 1