forked from zpltys/Othello
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SetTurn.java
63 lines (51 loc) · 1.53 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
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class SetTurn extends JFrame implements ActionListener{
private Label msg;
private JRadioButton white, black;
private ButtonGroup bg;
private JButton choose, cancel;
public MyMenu myMenu;
public SetTurn() {
white = new JRadioButton("White");
black = new JRadioButton("Black", true);
bg = new ButtonGroup();
bg.add(white);
bg.add(black);
msg = new Label("Please choose first turn");
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(choose);
panel.add(cancel);
add(panel);
setSize(200, 100);
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;
myMenu.setVisible(true);
dispose();
} else {
myMenu.setVisible(true);
dispose();
}
}
public static void main(String[] args) {
SetTurn s = new SetTurn();
}
}