Sei sulla pagina 1di 43

TIC-TAC-TOE GAME

M.C.A(Master of Computer
Applications)

THREE YEAR COURSE (4th SEMESTER)


2015

Submitted To:By:Prof. Amritpal Singh


Setia

Submitted
Rahul
Sukhpreet Kaur

Yadavindra COLLEGE OF ENGG.


TALWANDI SABO (BATHINDA)
Affiliated to:
PUNJABI UNIVERSITY PATIALA

TIC-TAC-TOE GAME
M.C.A (Master of Computer
Applications)

THREE YEAR COURSE (4th SEMESTER)


2015

Submitted To:By:Prof. Amritpal Singh

Submitted
Rahul Setia
Sukhpreet Kaur

YADAVINDRA COLLEGE OF ENGG.


TALWANDI SABO (BATHINDA)
affiliated to :- punjabi university patiala

ACKNOWLEDGMENT
I am thankful to the almighty with whose
grace I succeed in developing this project.
Before I get into think of the things, I
would like to thanks my teacher as up
who helped me in developing this project
and gave unending support at each stage.
I express my sincere feelings of gratitude
towards my project Co-ordinators Prof.
Amritpal Singh for his encouraging and
critical advice in completing this project.
My sincere thanks to my friends for their
whole hearted help during the tenure of
this work and providing the necessary
facilities. I greatly express my gratitude
for their involvement in the project.
Finally, I am thankful to all who so ever
has contributed in this project to all who
so ever has contributed in this project to
make it a success.
Sukhpreet Kaur

CERTIFICATE
This is here by certified that the project
report

of

Tic-Tac-Toe

Game

has

been

completed under my supervision by Rahul


Setia (2667) & Sukhpreet Kaur

(2675) of

MCA Fourth Sem at Yadavindra College of


Engg., Talwandi Sabo (Bathinda) affiliated to
Punjabi University, Patiala in the session
2014-15. The work done is the project is the
result candidates own efforts.

Prof.Amritpal Singh
Yadavindra College of Engg.
Talwandi Sabo (Bathinda)

DECLARATION
This is to certify that the project
report title TIC-TAC-TOE GAME is work
of students RAHUL SETIA and SUKHPREET
KAUR

student

of

MCA

(Master

of

Computer Applications) Three Year Course


4th

Sem

at

YADAVINDRA

COLLEGE

OF

ENGG., TALWANDI SABO (BATHINDA)


No

part

of

this

report

has

been

submitted to any other college/ university


for the reward of any degree to the best
of my knowledge.

Sukhpreet Kaur

Java language
Java is an object-oriented programming language with a built-in application
programming interface (API) that can handle graphics and user interfaces and that can be
used to create applications or applets. Because of its rich set of APIs, similar to
Macintosh and Windows, and its platform independence, Java can also be thought of as a
platform in itself. Java also has standard libraries for doing mathematics, some familiarity
with the syntax of C/C++ is useful.
In Java we distinguish between applications, which are programs that perform the
same functions as those written in other programming languages, and applets, which are
programs that can be embedded in a Web page and accessed over the Internet. Our initial
focus will be on writing applications. When a program is compiled, a byte code is
produced that can read and executed by any platform that can run Java.
FEATURES OF JAVA
Although the fundamental forces that necessitated the invention of Java are portability
and security, other factors also played an important role in molding the final form of the
language. The key considerations were summed up by the Java team in following list of
buzzwords:
1. Security
When we use a Java-compatible Web browser, we can safely download Java applets
without fear of viral infection or malicious intent. Java achieves this protection by
confining a Java program to the Java execution environment and not allowing it access to
other parts of the computer. The ability to download applets with confidence that no harm
will be done and that no security will be breached is considered by many to be the single
most important aspect of Java.
2. Portability
Many types of computers and operating systems are in use throughout the world and
many are connected to the Internet. For programs to be dynamically downloaded to all
the various types of platforms connected to the Internet, some means of generating
portable executable code is needed. As you will soon see, the same mechanism that helps
ensure security also helps create portability. Indeed, Javas solution to these two problems
is both the elegant and efficient.
3. Simple
Java was designed to be easy for the professional programmer to learn use
effectively. Assuming that you have some programming experience, you will not find
Java hard to master. If you already understand the basic concepts of object-oriented
programming, learning Java will be even easier.
4. Object-Oriented
Although influenced by its predecessors, Java was not designed to be source-code
compatible with any other language. This allowed the Java team the freedom to design
with a blank slate. One outcome of this was a clean, usable, pragmatic approach to
objects. Borrowing liberally from many seminal object-software environments of the last
few decades.

5. Robust
The multiplatform environment of the Web places extraordinary demands on a
program, because the program must execute reliably in a variety of systems. Thus, the
ability to create robust programs was given a high priority in the design of Java. To gain
reliability, Java restricts you in a few key areas, to force you to find your mistakes early
in program development. At the same time, Java frees you from having to worry about
many of the most common causes of programming errors. Because Java is a strictly typed
language, it checks your code at compile time. However, it also checks your code at
runtime.
6. Multithreaded
Java was designed to meet the real-world requirement of creating interactive,
networked programs. To accomplish this, Java supports multithreaded programming,
which allows you to write programs that do many things simultaneously. The Java runtime system comes with an elegant yet sophisticated solution for multiprocessor
synchronization that enables you to construct smoothly running interactive systems.
Javas easy-to-use approach to multithreading allows you to think about the specific
behavior of your program, not the multitasking subsystem.
7. Architecture-Neutral
A central issue for the Java designers was that of code longevity and portability. One
of the main problems facing programmers is that no guarantee exists that if you write a
program today, it will run tomorrow- even on the same machine. Operating system
upgrades, process upgrades, and and change in core system resource can all combine to
make a program malfunction. The Java designers made several hard decisions in the Java
language and the Java Virtual Machine in an attempt to alter this situation. Their goal was
Write once; Run anywhere, any time, forever. To a great extent, this goal was
accomplished.
8. Interpreted and High Performance
Java enables the creation of cross-platform programs by compiling into intermediate
representations called Java byte code. This code can be interpreted on any system that
provides a Java Virtual Machine. Most previous attempts at cross-platform solutions have
done so at the expense of performance.
9. Distributed
Java is designed for the distributed environment of the internet, because it handles
TCP/IP protocols. In fact, accessing a resource using a URL is not much different from
accessing a file. The original version of Java(Oak) included features for intra addressspace messaging. This allowed objects all to different computers to execute procedures
remotely.
10. Dynamic
Java programs carry with them substantial amounts of runtime type information that
is used to verify and resolve accesses to objects at run time. This makes it possible to
dynamically link code in a safe and expedient manner. This is crucial to the robustness of

the applet environment, in which small fragments of byte-code may be dynamically


updated on a running system.

Conclusion
The project was successfully completed after a lot of efforts & work hours. We have
carefully studied and analyzed each and every module of software and have tried to
solve it. The system has been developed for the given condition and is found working
effectively. The developed system is flexible and changes whenever can be made easy.
Using the facilities and functionalities of Java, the software have been developed in a
neat and simple manner, thereby reducing the operators work. The speed and accuracy
are maintained in proper way. The user friendly nature of the software developed in Java
language is very easy to work with

both for the higher management as well as other

employees with little knowledge of computer. The result obtained were fully satisfactory
from the user point of view. The system was verified with valid as well as invalid data in
each manner. The system is run with an insight into the necessary modifications that may
required in the future. Hence the system can be maintained successfully without much
network. Its hard to develop the perfect system in the very first effort. But our
satisfaction becomes more that we have submitted this project in time.
Sukhpreet Kaur

package game;

public class Game {

public static void main(String[] args) {


}
}

package game;
public class GameForm extends javax.swing.JFrame {
public GameForm() {
initComponents();
}
* This method is called from within the constructor to initialize the
form.
* WARNING: Do NOT modify this code. The content of this method is
always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
lbl3 = new javax.swing.JLabel();
lbl1 = new javax.swing.JLabel();
lbl2 = new javax.swing.JLabel();
lbl5 = new javax.swing.JLabel();
lbl6 = new javax.swing.JLabel();
lbl7 = new javax.swing.JLabel();
lbl4 = new javax.swing.JLabel();
lbl9 = new javax.swing.JLabel();
lbl8 = new javax.swing.JLabel();
lblr = new javax.swing.JLabel();
btnNew = new javax.swing.JButton();
jButton1 = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_
CLOSE);
lbl3.setBackground(new java.awt.Color(102, 255, 51));
lbl3.setFont(new java.awt.Font("Tahoma", 0, 48)); // NOI18N
lbl3.setBorder(javax.swing.BorderFactory.createLineBorder(new
java.awt.Color(0, 0, 0)));
lbl3.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {

lbl3Clicked(evt);
}
});
lbl1.setBackground(new java.awt.Color(255, 102, 51));
lbl1.setFont(new java.awt.Font("Tahoma", 0, 48)); // NOI18N
lbl1.setBorder(javax.swing.BorderFactory.createLineBorder(new
java.awt.Color(0, 0, 0)));
lbl1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
lbl1Clicked(evt);
}
});
lbl2.setBackground(new java.awt.Color(102, 255, 51));
lbl2.setFont(new java.awt.Font("Tahoma", 0, 48)); // NOI18N
lbl2.setBorder(javax.swing.BorderFactory.createLineBorder(new
java.awt.Color(0, 0, 0)));
lbl2.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
lbl2Clicked(evt);
}
});
lbl5.setBackground(new java.awt.Color(102, 255, 51));
lbl5.setFont(new java.awt.Font("Tahoma", 0, 48)); // NOI18N
lbl5.setBorder(javax.swing.BorderFactory.createLineBorder(new
java.awt.Color(0, 0, 0)));
lbl5.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
lbl5Clicked(evt);
}
});
lbl6.setBackground(new java.awt.Color(102, 255, 51));
lbl6.setFont(new java.awt.Font("Tahoma", 0, 48)); // NOI18N
lbl6.setBorder(javax.swing.BorderFactory.createLineBorder(new
java.awt.Color(0, 0, 0)));
lbl6.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
lbl6Clicked(evt);

}
});
lbl7.setBackground(new java.awt.Color(102, 255, 51));
lbl7.setFont(new java.awt.Font("Tahoma", 0, 48)); // NOI18N
lbl7.setBorder(javax.swing.BorderFactory.createLineBorder(new
java.awt.Color(0, 0, 0)));
lbl7.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
lbl7clikced(evt);
}
});
lbl4.setBackground(new java.awt.Color(102, 255, 51));
lbl4.setFont(new java.awt.Font("Tahoma", 0, 48)); // NOI18N
lbl4.setBorder(javax.swing.BorderFactory.createLineBorder(new
java.awt.Color(0, 0, 0)));
lbl4.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
lbl4Clicked(evt);
}
});
lbl9.setBackground(new java.awt.Color(102, 255, 51));
lbl9.setFont(new java.awt.Font("Tahoma", 0, 48)); // NOI18N
lbl9.setBorder(javax.swing.BorderFactory.createLineBorder(new
java.awt.Color(0, 0, 0)));
lbl9.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
lbl9Clicked(evt);
}
});
lbl8.setBackground(new java.awt.Color(102, 255, 51));
lbl8.setFont(new java.awt.Font("Tahoma", 0, 48)); // NOI18N
lbl8.setBorder(javax.swing.BorderFactory.createLineBorder(new
java.awt.Color(0, 0, 0)));
lbl8.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
lbl8Clicked(evt);
}
});

btnNew.setFont(new java.awt.Font("Comic Sans MS", 1, 14)); //


NOI18N
btnNew.setText("New Game");
btnNew.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
NewClicked(evt);
}
});
jButton1.setFont(new java.awt.Font("Comic Sans MS", 1, 14)); //
NOI18N
jButton1.setText("BACK");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(lbl1,
javax.swing.GroupLayout.PREFERRED_SIZE, 70,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UN
RELATED)
.addComponent(lbl2,
javax.swing.GroupLayout.PREFERRED_SIZE, 70,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UN
RELATED)

.addComponent(lbl3,
javax.swing.GroupLayout.PREFERRED_SIZE, 70,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(164, 164, 164))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alig
nment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(179, 179, 179)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alig
nment.LEADING, false)
.addGroup(layout.createSequentialGroup()
.addComponent(lbl7,
javax.swing.GroupLayout.PREFERRED_SIZE, 70,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RE
LATED, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(lbl8,
javax.swing.GroupLayout.PREFERRED_SIZE, 70,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UN
RELATED)
.addComponent(lbl9,
javax.swing.GroupLayout.PREFERRED_SIZE, 70,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(lbl4,
javax.swing.GroupLayout.PREFERRED_SIZE, 70,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UN
RELATED)
.addComponent(lbl5,
javax.swing.GroupLayout.PREFERRED_SIZE, 70,
javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UN
RELATED)
.addComponent(lbl6,
javax.swing.GroupLayout.PREFERRED_SIZE, 70,
javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGroup(layout.createSequentialGroup()
.addGap(41, 41, 41)
.addComponent(lblr))
.addGroup(layout.createSequentialGroup()
.addGap(167, 167, 167)
.addComponent(btnNew)
.addGap(55, 55, 55)
.addComponent(jButton1)))
.addContainerGap(164, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addGroup(layout.createSequentialGroup()
.addGap(19, 19, 19)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alig
nment.BASELINE)
.addComponent(btnNew)
.addComponent(jButton1))
.addGap(79, 79, 79)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alig
nment.BASELINE)
.addComponent(lbl2,
javax.swing.GroupLayout.PREFERRED_SIZE, 71,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lbl3,
javax.swing.GroupLayout.PREFERRED_SIZE, 71,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lbl1,
javax.swing.GroupLayout.PREFERRED_SIZE, 71,
javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UN
RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alig
nment.BASELINE)
.addComponent(lbl5,
javax.swing.GroupLayout.PREFERRED_SIZE, 71,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lbl6,
javax.swing.GroupLayout.PREFERRED_SIZE, 71,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lbl4,
javax.swing.GroupLayout.PREFERRED_SIZE, 71,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UN
RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alig
nment.BASELINE)
.addComponent(lbl7,
javax.swing.GroupLayout.PREFERRED_SIZE, 71,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lbl9,
javax.swing.GroupLayout.PREFERRED_SIZE, 71,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lbl8,
javax.swing.GroupLayout.PREFERRED_SIZE, 71,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RE
LATED, 94, Short.MAX_VALUE)
.addComponent(lblr)
.addGap(39, 39, 39))
);
pack();
}// </editor-fold>
public int check1(int i)
{

if((lbl1.getText() ==" O" && lbl2.getText() == " O" && lbl3.getText() == "
O")
|| (lbl1.getText() ==" O" && lbl4.getText() == " O" && lbl7.getText() == "
O")
|| (lbl1.getText() ==" O" && lbl5.getText() == " O" && lbl9.getText() ==
" O")
|| (lbl2.getText() ==" O" && lbl5.getText() == " O" && lbl8.getText() == "
O")
|| (lbl3.getText() ==" O" && lbl5.getText() == " O" && lbl7.getText() == "
O")
||(lbl3.getText() ==" O" && lbl6.getText() == " O" && lbl9.getText() == "
O")
|| (lbl4.getText() ==" O" && lbl5.getText() == " O" && lbl6.getText() == "
O")
|| (lbl7.getText() ==" O" && lbl8.getText() == " O" && lbl9.getText() == "
O"))
{
return 1;
}
if(lbl1.getText()!="" && lbl2.getText()!="" && lbl3.getText()!=""&&
lbl4.getText()!=""
&& lbl5.getText()!="" && lbl6.getText()!="" && lbl7.getText()!=""
&& lbl8.getText()!="" && lbl9.getText()!="")
{
lblr.setText("Draw....Please Try Again");
}
return 0;
}
public void check2()
{
if((lbl1.getText() ==" X" && lbl2.getText() == " X" && lbl3.getText() == "
X")
|| (lbl1.getText() ==" X" && lbl4.getText() == " X" && lbl7.getText() == "
X")
|| (lbl1.getText() ==" X" && lbl5.getText() == " X" && lbl9.getText() ==
" X")
|| (lbl2.getText() ==" X" && lbl5.getText() == " X" && lbl8.getText() == "
X")
|| (lbl3.getText() ==" X" && lbl5.getText() == " X" && lbl7.getText() == "
X")

||(lbl3.getText() ==" X" && lbl6.getText() == " X" && lbl9.getText() == "
X")
|| (lbl4.getText() ==" X" && lbl5.getText() == " X" && lbl6.getText() == "
X")
|| (lbl7.getText() ==" X" && lbl8.getText() == " X" && lbl9.getText() == "
X"))
{
lblr.setText("Computer Win......... Please Try Again");
}

public void ComputerTurn()


{
if( ((lbl1.getText() ==" O" && lbl2.getText() == " O" && lbl3.getText() !=
" X")
|| (lbl3.getText() == " O" && lbl2.getText() == " O" &&
lbl1.getText() != " X")
||(lbl1.getText() == " O"&& lbl3.getText() == " O" && lbl2.getText() !
= " X"))
|| ( (lbl1.getText() ==" X" && lbl2.getText() == " X" &&
lbl3.getText() != " O")
|| (lbl3.getText() == " X" && lbl2.getText() == " X" && lbl1.getText() !
= " O")
||(lbl1.getText() == " X"&& lbl3.getText() == " X" && lbl2.getText() !=
" O")))
{
if(lbl1.getText()=="")
lbl1.setText(" X");
else
if(lbl2.getText()=="")
lbl2.setText(" X");
else if (lbl3.getText()=="")
lbl3.setText(" X");
check2();
return;
}
if( ((lbl4.getText() ==" O" && lbl5.getText() == " O" && lbl6.getText() !=
" X")

|| (lbl5.getText() == " O" && lbl6.getText() == " O" &&


lbl4.getText() != " X")
||(lbl4.getText() == " O"&& lbl6.getText() == " O" && lbl5.getText() !
= " X"))
|| ((lbl4.getText() ==" X" && lbl5.getText() == " X" &&
lbl6.getText() != " O")
|| (lbl5.getText() == " X" && lbl6.getText() == " X" && lbl4.getText() !
= " O")
||(lbl4.getText() == " X"&& lbl6.getText() == " X" && lbl5.getText() !=
" O")))
{
if(lbl4.getText()=="")
lbl4.setText(" X");
else
if(lbl5.getText()=="")
lbl5.setText(" X");
else if (lbl6.getText()=="")
lbl6.setText(" X");
check2();
return;
}
if( ((lbl7.getText() ==" O" && lbl8.getText() == " O" && lbl9.getText() !=
" X")
|| (lbl8.getText() == " O" && lbl9.getText() == " O" &&
lbl7.getText() != " X")
||(lbl7.getText() == " O"&& lbl9.getText() == " O" && lbl8.getText() !
= " X"))
||((lbl7.getText() ==" X" && lbl8.getText() == " X" && lbl9.getText()
!= " O")
|| (lbl8.getText() == " X" && lbl9.getText() == " X" && lbl7.getText() !
= " O")

||(lbl7.getText() == " X"&& lbl9.getText() == " X" && lbl8.getText() != " O")))
{
if(lbl7.getText()=="")
lbl7.setText(" X");
else
if(lbl8.getText()=="")
lbl8.setText(" X");
else if (lbl9.getText()=="")
lbl9.setText(" X");
check2();
return;
}
if( ((lbl1.getText() ==" O" && lbl4.getText() == " O" && lbl7.getText() != " X")
|| (lbl4.getText() == " O" && lbl7.getText() == " O" && lbl1.getText() != " X")
||(lbl1.getText() == " O"&& lbl7.getText() == " O" && lbl4.getText() != " X"))
|| ((lbl1.getText() ==" X" && lbl4.getText() == " X" && lbl7.getText() != " O")
|| (lbl4.getText() == " X" && lbl7.getText() == " X" && lbl1.getText() != " O")
||(lbl1.getText() == " X"&& lbl7.getText() == " X" && lbl4.getText() != " O")))
{
if(lbl1.getText()=="")
lbl1.setText(" X");
else
if(lbl4.getText()=="")
lbl4.setText(" X");
else if (lbl7.getText()=="")
lbl7.setText(" X");
check2();
return;
}
if( ((lbl2.getText() ==" O" && lbl5.getText() == " O" && lbl8.getText() != " X")
|| (lbl5.getText() == " O" && lbl8.getText() == " O" && lbl2.getText() != " X")
||(lbl2.getText() == " O"&& lbl8.getText() == " O" && lbl5.getText() != " X"))
||((lbl2.getText() ==" X" && lbl5.getText() == " X" && lbl8.getText() != " O")
|| (lbl5.getText() == " X" && lbl8.getText() == " X" && lbl2.getText() != " O")
||(lbl2.getText() == " X"&& lbl8.getText() == " X" && lbl5.getText() != " O")))
{
if(lbl5.getText()=="")
lbl5.setText(" X");
else
if(lbl2.getText()=="")
lbl2.setText(" X");
else if (lbl8.getText()=="")
lbl8.setText(" X");
check2();
return;
}
if( ((lbl3.getText() ==" O" && lbl6.getText() == " O" && lbl9.getText() != " X")
|| (lbl6.getText() == " O" && lbl9.getText() == " O" && lbl3.getText() != " X")
||(lbl3.getText() == " O"&& lbl9.getText() == " O" && lbl6.getText() != " X"))

||((lbl3.getText() ==" X" && lbl6.getText() == " X" && lbl9.getText() != " Y")
|| (lbl6.getText() == " X" && lbl9.getText() == " X" && lbl3.getText() != " Y")
||(lbl3.getText() == " X"&& lbl9.getText() == " X" && lbl6.getText() != " Y")))
{
if(lbl3.getText()=="")
lbl3.setText(" X");
else
if(lbl6.getText()=="")
lbl6.setText(" X");
else if (lbl9.getText()=="")
lbl9.setText(" X");
check2();
return;
}
if( ((lbl1.getText() ==" O" && lbl5.getText() == " O" && lbl9.getText() != " X")
|| (lbl5.getText() == " O" && lbl9.getText() == " O" && lbl1.getText() != " X")
||(lbl1.getText() == " O"&& lbl9.getText() == " O" && lbl5.getText() != " X"))
||((lbl1.getText() ==" X" && lbl5.getText() == " X" && lbl9.getText() != " O")
|| (lbl5.getText() == " X" && lbl9.getText() == " X" && lbl1.getText() != " O")
||(lbl1.getText() == " X"&& lbl9.getText() == " X" && lbl5.getText() != " O")))
{
if(lbl1.getText()=="")
lbl1.setText(" X");
else
if(lbl5.getText()=="")
lbl5.setText(" X");
else if (lbl9.getText()=="")
lbl9.setText(" X");
check2();
return;
}
if( ((lbl3.getText() ==" O" && lbl5.getText() == " O" && lbl7.getText() != " X")
|| (lbl5.getText() == " O" && lbl7.getText() == " O" && lbl3.getText() != " X")
||(lbl7.getText() == " O"&& lbl3.getText() == " O" && lbl5.getText() != " X"))
|| (lbl3.getText() ==" X" && lbl5.getText() == " X" && lbl7.getText() != " O")
|| (lbl5.getText() == " X" && lbl7.getText() == " X" && lbl3.getText() != " O")
||(lbl7.getText() == " X"&& lbl3.getText() == " X" && lbl5.getText() != " O"))
{
if(lbl3.getText()=="")
lbl3.setText(" X");
else
if(lbl5.getText()=="")
lbl5.setText(" X");
else if (lbl7.getText()=="")
lbl7.setText(" X");
check2();
return;
}

if(lbl5.getText()== "" )
{
lbl5.setText(" X");
}
else if(lbl3.getText()== "")
{
lbl3.setText(" X");
}
else if(lbl7.getText()== "")
{
lbl7.setText(" X");
}
else if(lbl1.getText()== "")
{
lbl1.setText(" X");
}
else if(lbl9.getText()== "")
{
lbl9.setText(" X");
}
else if(lbl2.getText()== "")
{
lbl2.setText(" X");
}
else if(lbl4.getText()== "")
{
lbl4.setText(" X");
}
else if(lbl6.getText()== "")
{
lbl6.setText(" X");
}
else if(lbl8.getText()== "")
{
lbl8.setText(" X");
}
check2();
}
private void lbl1Clicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
if(lbl1.getText()== "")
{
lbl1.setText(" O");
if(check1(1)== 1)
{
lblr.setText("You Win..........");
}
ComputerTurn();

}
}
private void lbl2Clicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
if(lbl2.getText()== "")
{
lbl2.setText(" O");
if(check1(1)== 1)
{
lblr.setText("You Win..........");
}
ComputerTurn();
}
}
private void lbl3Clicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
if(lbl3.getText()== "")
{
lbl3.setText(" O");
if(check1(1)== 1)
{
lblr.setText("You Win..........");
}
ComputerTurn();
}
}
private void lbl4Clicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
if(lbl4.getText()== "")
{
lbl4.setText(" O");
if(check1(1)== 1)
{
lblr.setText("You Win..........");
}
ComputerTurn();
}
}
private void lbl5Clicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
if(lbl5.getText()== "")
{
lbl5.setText(" O");
if(check1(1)== 1)

{
lblr.setText("You Win..........");
}
ComputerTurn();
}
}
private void lbl6Clicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
if(lbl6.getText()== "")
{
lbl6.setText(" O");
if(check1(1)== 1)
{
lblr.setText("You Win..........");
}
ComputerTurn();
}
}
private void lbl7clikced(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
if(lbl7.getText()== "")
{
lbl7.setText(" O");
if(check1(1)== 1)
{
lblr.setText("You Win..........");
}
ComputerTurn();
}
}
private void lbl8Clicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
if(lbl8.getText()== "")
{
lbl8.setText(" O");
if(check1(1)== 1)
{
lblr.setText("You Win..........");
}
ComputerTurn();
}
}
private void lbl9Clicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:

if(lbl9.getText()== "")
{
lbl9.setText(" O");
if(check1(1)== 1)
{
lblr.setText("You Win..........");
}
ComputerTurn();
}
}
private void NewClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
lbl1.setText("");
lbl2.setText("");
lbl3.setText("");
lbl4.setText("");
lbl5.setText("");
lbl6.setText("");
lbl7.setText("");
lbl8.setText("");
lbl9.setText("");
lblr.setText("");

}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
instructions in=new instructions();
in.show();
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional)
">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());

break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(GameForm.class.getName()).log(java.util.loggin
g.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(GameForm.class.getName()).log(java.util.loggin
g.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(GameForm.class.getName()).log(java.util.loggin
g.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(GameForm.class.getName()).log(java.util.loggin
g.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new GameForm().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton btnNew;
private javax.swing.JButton jButton1;
private javax.swing.JLabel lbl1;
private javax.swing.JLabel lbl2;
private javax.swing.JLabel lbl3;
private javax.swing.JLabel lbl4;
private javax.swing.JLabel lbl5;
private javax.swing.JLabel lbl6;
private javax.swing.JLabel lbl7;
private javax.swing.JLabel lbl8;
private javax.swing.JLabel lbl9;
private javax.swing.JLabel lblr;
// End of variables declaration
}

package game;
public class history extends javax.swing.JFrame {
public history() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jButton1 = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
jLabel1 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jButton1.setFont(new java.awt.Font("Harrington", 1, 18)); // NOI18N
jButton1.setText("BACK");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jTextArea1.setColumns(20);
jTextArea1.setFont(new java.awt.Font("Harrington", 1, 18)); // NOI18N
jTextArea1.setLineWrap(true);
jTextArea1.setRows(5);
jTextArea1.setText(" Tic-tac-toe, also know as Naughts and Crosses, is one of the
most widely known games. Found everywhere from the temples of ancient Egypt to the
medieval cathedrals of England, tic-tac-toe has entertained people for centuries. While tictac-toe is now considered to be a child's game, it was not always the case. In the past, the
game was linked to pagan rituals dedicated to the magic properties of the nine-square
grid. The grid was known as the Magic Square because the numbers 1-9 could be arranged
so that their sum is the same horizontally, diagonally or vertically. During the Middle Ages,
the Magic Square was known by secret societies as the Cabala of the Nine Chambers.
They believed that the Magic Square held a numerological message about the world.
Today, the game is more known as a simple childhood pastime. While in the United States,
the game is known as tic-tac-toe, the original name of \"Tit-Tat-Toe\" comes to us from the

16th century. Tit by itself means to slap and a \"tit for tat\" is retaliation. Toe, which is the
third piece placed makes the winning combination by securing the other two pieces.
Recently tic-tac-toe reached stardom on the big screen in the Hollywood film Wargames,
where tic-tac-toe was used to teach a super-computer about no-win situations.");
jScrollPane1.setViewportView(jTextArea1);
jLabel1.setFont(new java.awt.Font("Harrington", 1, 36)); // NOI18N
jLabel1.setText("HISTORY");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addContainerGap(45, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jButton1)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addComponent(jLabel1)
.addGap(354, 354, 354))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE, 755,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(40, 40, 40)))))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 382,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton1)
.addGap(61, 61, 61))
);
pack();

}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
instructions i=new instructions();
i.show();
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(history.class.getName()).log(java.util.logging.Level.SEV
ERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(history.class.getName()).log(java.util.logging.Level.SEV
ERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(history.class.getName()).log(java.util.logging.Level.SEV
ERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(history.class.getName()).log(java.util.logging.Level.SEV
ERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {

new history().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea jTextArea1;
// End of variables declaration
}

package game;
import java.sql.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
public class instructions extends javax.swing.JFrame {
public instructions() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jButton1 = new javax.swing.JButton();
jTextField1 = new javax.swing.JTextField();
jTextField2 = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
jButton5 = new javax.swing.JButton();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jButton1.setFont(new java.awt.Font("Comic Sans MS", 1, 11)); // NOI18N
jButton1.setText("ENTER");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jTextField1.setFont(new java.awt.Font("Comic Sans MS", 1, 11)); // NOI18N
jTextField2.setFont(new java.awt.Font("Comic Sans MS", 1, 11)); // NOI18N
jLabel1.setFont(new java.awt.Font("Comic Sans MS", 1, 11)); // NOI18N

jLabel2.setFont(new java.awt.Font("Comic Sans MS", 1, 11)); // NOI18N


jLabel2.setText("NAME");
jLabel3.setFont(new java.awt.Font("Comic Sans MS", 1, 11)); // NOI18N
jLabel3.setText("E-MAIL");
jButton2.setFont(new java.awt.Font("Comic Sans MS", 1, 11)); // NOI18N
jButton2.setText("RULES");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jButton3.setFont(new java.awt.Font("Comic Sans MS", 1, 11)); // NOI18N
jButton3.setText("PLAY");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
jButton4.setFont(new java.awt.Font("Comic Sans MS", 1, 11)); // NOI18N
jButton4.setText("QUIT");
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});
jButton5.setFont(new java.awt.Font("Comic Sans MS", 1, 11)); // NOI18N
jButton5.setText("HISTORY");
jButton5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton5ActionPerformed(evt);
}
});
jLabel4.setFont(new java.awt.Font("Forte", 1, 36)); // NOI18N
jLabel4.setText("WELCOME");
jLabel5.setFont(new java.awt.Font("Comic Sans MS", 1, 14)); // NOI18N
jLabel5.setText("If you don't want to enter your name, e-mail just click PLAY to Play.");
jLabel6.setFont(new java.awt.Font("Comic Sans MS", 1, 14)); // NOI18N
jLabel6.setText("Tic-tac-toe is a fun game that you can play any time just click PLAY
to play. ");

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(233, 233, 233)
.addComponent(jLabel4))
.addGroup(layout.createSequentialGroup()
.addGap(44, 44, 44)
.addComponent(jLabel6))
.addGroup(layout.createSequentialGroup()
.addGap(83, 83, 83)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
.addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, 418,
Short.MAX_VALUE)
.addComponent(jButton4, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addGroup(layout.createSequentialGroup()
.addGap(36, 36, 36)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel5)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel2)
.addGap(30, 30, 30)
.addComponent(jTextField1,
javax.swing.GroupLayout.PREFERRED_SIZE, 145,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel3,
javax.swing.GroupLayout.PREFERRED_SIZE, 59,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(jTextField2,
javax.swing.GroupLayout.PREFERRED_SIZE, 151,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton1))))))
.addContainerGap(35, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(26, 26, 26)
.addComponent(jLabel4)
.addGap(18, 18, 18)
.addComponent(jLabel6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton3)
.addGap(11, 11, 11)
.addComponent(jButton2)
.addGap(18, 18, 18)
.addComponent(jButton5)
.addGap(11, 11, 11)
.addComponent(jButton4)
.addGap(47, 47, 47)
.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 19,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton1))
.addGap(26, 26, 26)
.addComponent(jLabel1)
.addGap(115, 115, 115))
);
pack();
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
try
{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection connect =DriverManager.getConnection("jdbc:odbc:gamedb");
Statement st2=connect.createStatement();
if(st2.executeUpdate("Insert into Table1([name],[email]) values('"+jTextField1.getText()
+"','"+jTextField2.getText()+"')")==1)
{
jLabel1.setText("NOW YOU CAN PLAY!!!!!!!!!!");
}
}
catch(Exception e)
{
jLabel1.setText(e.getMessage()) ;
}
jTextField1.setText("");
jTextField2.setText("");
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
rules r=new rules();
r.show();
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
GameForm g=new GameForm();
g.show();
}
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0);
}
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
history h=new history();
h.show();
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/

try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(instructions.class.getName()).log(java.util.logging.Leve
l.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(instructions.class.getName()).log(java.util.logging.Leve
l.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(instructions.class.getName()).log(java.util.logging.Leve
l.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(instructions.class.getName()).log(java.util.logging.Leve
l.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new instructions().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JButton jButton5;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;

// End of variables declaration


}
package game;
public class rules extends javax.swing.JFrame {
public rules() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setFont(new java.awt.Font("Comic Sans MS", 1, 24)); // NOI18N
jLabel1.setText("How to Play Tic Tac Toe");
jLabel2.setFont(new java.awt.Font("Comic Sans MS", 1, 18)); // NOI18N
jLabel2.setText("1. The game is played on a grid that's 3 squares by 3 squares.");
jButton1.setFont(new java.awt.Font("Comic Sans MS", 1, 18)); // NOI18N
jButton1.setText("BACK");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jLabel3.setFont(new java.awt.Font("Comic Sans MS", 1, 18)); // NOI18N
jLabel3.setText("2. You are X, your computer in this case is O. Players take turns");

jLabel4.setFont(new java.awt.Font("Comic Sans MS", 1, 18)); // NOI18N


jLabel4.setText("3. The first player to get 3 marks in a row (up, down, across, or ");
jLabel5.setFont(new java.awt.Font("Comic Sans MS", 1, 18)); // NOI18N
jLabel5.setText("4. When all 9 squares are full, the game is over. If no player has ");
jLabel6.setFont(new java.awt.Font("Comic Sans MS", 1, 18)); // NOI18N
jLabel6.setText("putting their marks in empty squares.");
jLabel7.setFont(new java.awt.Font("Comic Sans MS", 1, 18)); // NOI18N
jLabel7.setText("diagonally) is the winner.");
jLabel8.setFont(new java.awt.Font("Comic Sans MS", 1, 18)); // NOI18N
jLabel8.setText(" 3 marks in a row, the game ends in a tie.");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(167, 167, 167)
.addComponent(jLabel1)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addGap(0, 46, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3)
.addComponent(jLabel4)
.addComponent(jLabel5)
.addGroup(layout.createSequentialGroup()
.addGap(24, 24, 24)
.addComponent(jLabel6))
.addGroup(layout.createSequentialGroup()
.addGap(27, 27, 27)
.addComponent(jLabel7))
.addGroup(layout.createSequentialGroup()
.addGap(23, 23, 23)
.addComponent(jLabel8))
.addComponent(jLabel2))
.addGap(37, 37, 37))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton1)
.addGap(94, 94, 94))
);

layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(64, 64, 64)
.addComponent(jLabel1)
.addGap(39, 39, 39)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 21,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 21,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jLabel6)
.addGap(18, 18, 18)
.addComponent(jLabel4)
.addGap(18, 18, 18)
.addComponent(jLabel7)
.addGap(18, 18, 18)
.addComponent(jLabel5)
.addGap(18, 18, 18)
.addComponent(jLabel8)
.addGap(18, 18, 18)
.addComponent(jButton1)
.addContainerGap(50, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
instructions b=new instructions();
b.show();
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {

javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(rules.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(rules.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(rules.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(rules.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new rules().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
// End of variables declaration
}

Potrebbero piacerti anche