-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGame.java
More file actions
50 lines (37 loc) · 1.09 KB
/
Game.java
File metadata and controls
50 lines (37 loc) · 1.09 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
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Game extends JPanel {
private JFrame frame;
private JPanel currentScreen;
public Game() {
frame = new JFrame("Chipotle Vault");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(500, 750);
frame.setLayout(null);
}
public void startGame() {
setScreen(new HomeScreen(this));
frame.setVisible(true);
}
void setScreen(JPanel screen) {
if (currentScreen != null) {
frame.remove(currentScreen);
}
currentScreen = screen;
frame.add(currentScreen);
frame.revalidate();
frame.repaint();
}
public JFrame getFrame() {
return frame;
}
public void setFrame(JFrame frame) {
this.frame = frame;
}
public JPanel getCurrentScreen() {
return currentScreen;
}
public void setCurrentScreen(JPanel currentScreen) {
this.currentScreen = currentScreen;
}
}