-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFrame.java
More file actions
57 lines (48 loc) · 1.29 KB
/
Frame.java
File metadata and controls
57 lines (48 loc) · 1.29 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
import javax.swing.JFrame;
import java.awt.BorderLayout;
public class Frame extends JFrame{
HomePanel home;
InstuctionPanel credit;
GamePanel game;
EndingPanel ending;
public Frame(){
setTitle("Space Invader");
setSize(1280,720);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setResizable(false);
home = new HomePanel(this);
add(home,BorderLayout.CENTER);
credit = new InstuctionPanel(this);
game = new GamePanel(this);
ending = new EndingPanel(this);
}
public void showFrame(){
setVisible(true);
}
public void showCreditPanel(){
getContentPane().removeAll();
add(credit, BorderLayout.CENTER);
revalidate();
repaint();
}
public void showHomePanel(){
getContentPane().removeAll();
add(home, BorderLayout.CENTER);
revalidate();
repaint();
}
public void showGamePanel(){
getContentPane().removeAll();
add(game, BorderLayout.CENTER);
revalidate();
repaint();
}
public void showEndingPanel(){
getContentPane().removeAll();
game = null;
System.gc();
add(ending, BorderLayout.CENTER);
revalidate();
repaint();
}
}