-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnd_Panel.java
More file actions
78 lines (67 loc) · 2.11 KB
/
End_Panel.java
File metadata and controls
78 lines (67 loc) · 2.11 KB
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
import javax.swing.*;
import java.awt.*;
public class End_Panel extends JPanel
{
boolean win;
JButton try_again = new JButton("Try Again");
JButton play_again = new JButton("Play Again");
JFrame frame;
static boolean again = false;
JPanel game;
public End_Panel(boolean w,JFrame f,JPanel p)
{
win = w;
frame = f;
game = p;
if(win)
{
add(play_again);
play_again.addActionListener(new ButtonListener(new JLabel()));
repaint();
}
else
{
add(try_again);
try_again.addActionListener(new ButtonListener(new JLabel()));
repaint();
}
}
public void paintComponent(Graphics g)
{
g.setFont(new Font("Times New Roman",Font.BOLD,40));
Color bg = new Color(179, 177, 177, 98);
if(win)
{
buttonSet(play_again,235,300,bg,Color.BLACK);
g.fillRect(0, 0, 1000, 1000);
g.setColor(Color.white);
g.drawString("YOU WON!", 200, 200);
g.setFont(new Font("Times New Roman",Font.BOLD,20));
g.drawString("Time remaining: " + Detyra.digitFixer(Detyra.count/60 + "") + ":" + Detyra.digitFixer(Detyra.count%60 + ""),210,260);
}
else
{
buttonSet(try_again,235,250,bg,Color.BLACK);
g.fillRect(0, 0, 1000, 1000);
g.setColor(Color.white);
g.drawString("YOU LOST!", 200, 200);
}
if(again)
{
Detyra.reset_boolean = true;
frame.getContentPane().add(game);
Detyra.timer_label.setText("Time remaining: 04:00");
frame.getContentPane().remove(this);
frame.repaint();
}
repaint();
}
public void buttonSet(JButton b,int x,int y, Color c,Color c2)
{
b.setMargin(new Insets(0, 0, 0, 0));
b.setBounds(x,y,140,30);
b.setBackground(c);
b.setForeground(c2);
b.setFont(new Font("Arial",Font.PLAIN,17));
}
}