-
Notifications
You must be signed in to change notification settings - Fork 1
/
SetTurn.java
85 lines (67 loc) · 2.13 KB
/
SetTurn.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
84
85
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class SetTurn extends JFrame implements ActionListener{
private Label msg, hardChoose;
private JRadioButton white, black, simple, midium, hard;
private ButtonGroup bg, hc;
private JButton choose, cancel;
public MyMenu myMenu;
public SetTurn() {
white = new JRadioButton("White");
black = new JRadioButton("Black", true);
hard = new JRadioButton("hard");
midium = new JRadioButton("medium");
simple = new JRadioButton("simple", true);
bg = new ButtonGroup();
bg.add(white);
bg.add(black);
hc = new ButtonGroup();
hc.add(simple);
hc.add(midium);
hc.add(hard);
msg = new Label("Please choose first turn");
hardChoose = new Label("Please choose hard level");
choose = new JButton("choose");
choose.addActionListener(this);
cancel = new JButton("cancel");
cancel.addActionListener(this);
JPanel panel = new JPanel();
panel.setLayout(new FlowLayout());
panel.add(msg);
panel.add(black);
panel.add(white);
panel.add(hardChoose);
panel.add(simple);
panel.add(midium);
panel.add(hard);
panel.add(choose);
panel.add(cancel);
add(panel);
setSize(225, 150);
setLocation(300, 250);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
public void actionPerformed(ActionEvent e) {
JButton s = (JButton)e.getSource();
if(s == choose) {
int turn;
if(black.isSelected()) turn = 1;
else turn = 2;
myMenu.turn = turn;
int level = 3;
if(midium.isSelected()) level = 4;
if(hard.isSelected()) level = 5;
myMenu.level = level;
myMenu.setVisible(true);
dispose();
} else {
myMenu.setVisible(true);
dispose();
}
}
public static void main(String[] args) {
SetTurn s = new SetTurn();
}
}