tags:

views:

89

answers:

1

On exiting my game, I would like to show an "exitscreen". The exitscreen.gif is in the folder, and works fine, but for some reason, only the blank frame shows with this:

JPanel finishPanel = new JPanel();
JLabel finishLabel = new JLabel(new ImageIcon("welcomescreen.gif"));
finishPanel.add(finishLabel);
finishLabel.setSize(11 * 35, 11 * 35);
finishPanel.setPreferredSize(finishLabel.getSize());
this.frame.setVisible(false);
JFrame exitFrame = new JFrame("Thanks for playing");
exitFrame.getContentPane().add(finishPanel);
exitFrame.setLocationRelativeTo(null);
exitFrame.pack();
exitFrame.setVisible(true);
finishLabel.setVisible(true);

this.frame is just another JFrame I don't need anymore.

+5  A: 

Your code looks fine and even works fine for me. I guess the problem is the placement of the welcome.gif file.

Even I got a blank screen first, but then I move the welcome.gif to the proper location which is under directly the root of the project.

Bragboy