Reputation: 859
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.
Upvotes: 3
Views: 943
Reputation: 35542
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.
http://img15.imageshack.us/img15/4821/screenshotuct.png
http://img693.imageshack.us/img693/6301/locationy.png
Upvotes: 5