-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEndPanel.java
85 lines (73 loc) · 2.73 KB
/
EndPanel.java
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import java.awt.*; // access to Container
import java.awt.event.*; // access to WindowAdapter, WindowEvent
import javax.swing.*; // access to JFrame and Jcomponents
import javax.swing.event.*; // access to JSlider events
import javax.swing.Timer;
/**
* Write a description of class EndPanel here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class EndPanel extends JLayeredPane implements ActionListener
{
// instance variables - replace the example below with your own
MBFrame myFrame; //Frame for screens
JLabel endingScreen; //Background image
JButton playAgain; //restarts game if pressed
JLabel win; // displays message (win)
JLabel lose; //displays message (lose)
JLabel lose2;
/**
* Constructor for objects of class EndPanel
*/
public EndPanel(MBFrame frame)
// instantiates instance variables
{
myFrame = frame;
playAgain = new JButton();
ImageIcon playImage = new ImageIcon(getClass().getResource("assets/play button.png"));
ImageIcon rolloverImage = new ImageIcon(getClass().getResource("assets/hoverplay.png"));
playAgain.setFocusable(false);
playAgain.setBounds(385,390,230,72);
playAgain.addActionListener(this);
playAgain.setIcon(playImage);
playAgain.setBackground(new Color(0xFAE7B5));
playAgain.setContentAreaFilled(false);
playAgain.setBorder(null);
playAgain.setRolloverEnabled(true);
playAgain.setRolloverIcon(rolloverImage);
win = new JLabel();
ImageIcon slayIMG = new ImageIcon(getClass().getResource("assets/slay.png"));
win.setIcon(slayIMG);
win.setBounds(0,0, 100, 100);
lose = new JLabel();
ImageIcon wrongIMG = new ImageIcon(getClass().getResource("assets/wrong.png"));
lose.setIcon(wrongIMG);
lose.setBounds(0,0, 100, 100);
lose2 = new JLabel();
ImageIcon minionbeach = new ImageIcon(getClass().getResource("assets/Minion Beach.png"));
lose2.setIcon(minionbeach);
lose2.setBounds(0,0,1000,750);
}
public void actionPerformed(ActionEvent event)
//Creates new MBFrame when pressed
{
if(event.getSource() == playAgain){
myFrame.setVisible(false);
MBFrame newFrame = new MBFrame();
}
}
public void updateEnd()
//Displays correct result image
{
this.add(playAgain,0);
if(myFrame.getScore() >=100){
this.add(win);
}else if(myFrame.getScore() <100){
this.add(lose2);
this.add(lose);
this.moveToFront(lose);
}
}
}