-
Notifications
You must be signed in to change notification settings - Fork 0
/
LaunchGameGUI.java
83 lines (69 loc) · 1.81 KB
/
LaunchGameGUI.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
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
79
80
81
82
83
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
public class LaunchGameGUI extends JPanel
{
JButton start;
JButton save;
JButton pass;
private GameSettingGUI setting;
private GridBagConstraints gbc = new GridBagConstraints();
private ConfirmPressed confirm;
private GameControl control;
// constructor
public LaunchGameGUI()
{
confirm = new ConfirmPressed();
start = new JButton("New Game");
save = new JButton("Save Game");
pass = new JButton("Pass Turn");
start.setPreferredSize(new Dimension(100, 100));
save.setPreferredSize(new Dimension(100, 100));
pass.setPreferredSize(new Dimension(100, 100));
setLayout(new GridBagLayout());
gbc.gridx = 0;
gbc.gridy = 0;
add(start, gbc);
gbc.gridx = 0;
gbc.gridy = 1;
add(save, gbc);
gbc.gridx = 0;
gbc.gridy = 2;
add(pass, gbc);
setPreferredSize(new Dimension(130, 90));
start.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
setting = new GameSettingGUI(confirm);
// additional part
confirm.setGameSettingGUI(setting);
// additional part
confirm.setControl(control);
}
}
);
pass.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
control.passTurn();
}
}
);
save.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
control.save();
}
}
);
}
public void setControl(GameControl c)
{
control = c;
}
}