-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnd.java
More file actions
38 lines (34 loc) · 852 Bytes
/
End.java
File metadata and controls
38 lines (34 loc) · 852 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
32
33
34
35
36
37
38
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class End extends JPanel implements ActionListener{
Message m;
JButton b;
Base base;
public End(Base ba, String s, int h, int m){
base = ba;
setLayout(new BorderLayout());
m = new Message(s, h, m);
b = new JButton("Go Back to Home");
b.addActionListener(this);
add(b, BorderLayout.SOUTH);
add(m, BorderLayout.CENTER);
}
public void actionPerformed(ActionEvent e){
base.showIt("home");
}
}
class Message extends JPanel {
String message;
int hours;
int minutes;
public Message(String s, int h, int m){
message = s;
hours = h;
mintues = m;
}
public void paintComponent(Graphics g){
super.paintComponent(g);
g.drawString("You have " + message + " " + hours + " hours and " + minutes + " minutes.", (getWidth()/2)-10, getHeight()/2);
}
}