-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainLayoutPanel.java
50 lines (34 loc) · 1.09 KB
/
MainLayoutPanel.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
package minesweeper;
import java.awt.CardLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JPanel;
class MainLayoutPanel extends JPanel {
private DifficultyPanel difficulty;
private GameLayoutPanel gameLayout;
private CardLayout cardLayout;
private JPanel cards;
public MainLayoutPanel() {
cardLayout = new CardLayout();
setLayout(cardLayout);
difficulty = new DifficultyPanel();
ButtonHandler handler = new ButtonHandler();
JButton play = new JButton("Play Game");
play.addActionListener(handler);
difficulty.add(play);
add(difficulty, "Difficulty");
cardLayout.show(this, "Difficulty");
}
public void startGame(){
gameLayout = new GameLayoutPanel(difficulty.getDifficulty());
add(gameLayout, "Game Layout");
cardLayout.show(this, "Game Layout");
}
private class ButtonHandler implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
startGame();
}
}
}