-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStart.java
More file actions
112 lines (89 loc) · 2.23 KB
/
Copy pathStart.java
File metadata and controls
112 lines (89 loc) · 2.23 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
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import java.lang.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.event.*;
public class Start extends JFrame implements ActionListener
{
JButton play,exit;
JRadioButton r1,r2;
JLabel title,choise,invalid;
JPanel panel;
JRadioButton x,y;
ButtonGroup bg1;
public Start()
{
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(300,100,900,800);
setTitle("Tic Tac Toe");
panel = new JPanel();
panel.setLayout(null);
title=new JLabel("TiC taC tOe");
title.setFont(new Font("CASTELLAR",Font.BOLD,50));
title.setBounds(170,100,500,80);
panel.add(title);
choise=new JLabel("choose your character : ");
choise.setFont(new Font("ARIAL",Font.BOLD,15));
choise.setBounds(180,200,200,30);
panel.add(choise);
/*
String s[]={"O","X"};
JComboBox c=new JComboBox(s);
c.setBounds(390,210,50,20);
panel.add(c);
*/
r1 = new JRadioButton("X");
r1.setBounds(390,200,50,30);
panel.add(r1);
r2 = new JRadioButton("O");
r2.setBounds(390,245,50,30);
panel.add(r2);
bg1 = new ButtonGroup();
bg1.add(r1);
bg1.add(r2);
invalid=new JLabel("*choose character");
invalid.setFont(new Font("CARIAL",Font.BOLD,15));
invalid.setBounds(445,245,300,30);
invalid.setForeground(Color.RED);
invalid.setVisible(false);
panel.add(invalid);
play=new JButton("PLAY");
play.setBounds(260,300,80,40);
play.addActionListener(this);
panel.add(play);
exit=new JButton("EXIT");
exit.setBounds(400,300,80,40);
exit.addActionListener(this);
panel.add(exit);
this.add(panel);
}
public void actionPerformed(ActionEvent e)
{
invalid.setVisible(false);
if(e.getSource().equals(play))
{
if(r1.isSelected())
{
Game game=new Game('X');
setVisible(false);
game.setVisible(true);
}
else if(r2.isSelected())
{
Game game=new Game('O');
setVisible(false);
game.setVisible(true);
}
else invalid.setVisible(true);
}
else if(e.getSource().equals(exit))
{
System.exit(0);
}
}
public static void main(String args[])
{
Start s=new Start();
s.setVisible(true);
}
}