-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLoser.java
More file actions
31 lines (27 loc) · 899 Bytes
/
Loser.java
File metadata and controls
31 lines (27 loc) · 899 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import java.io.File;
import java.io.InputStream;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import javax.swing.*;
// Class to notify player game is over
public class Loser {
// Method that notifies player of loss and returns JLabel
public JLabel gameOver() {
BufferedImage imageLose = null;
try
{
InputStream is = Roadrunner.class.getResourceAsStream("/youLose.png");
imageLose = ImageIO.read(is);
}
catch (Exception e)
{
e.printStackTrace();
System.exit(1);
}
ImageIcon imageLoseIcon = new ImageIcon(imageLose);
JLabel jLabelLose = new JLabel();
jLabelLose.setIcon(imageLoseIcon);
jLabelLose.setBounds(300, 300, imageLoseIcon.getIconWidth() + 20, imageLoseIcon.getIconHeight() + 20);
return jLabelLose;
}
}