HDTutorial
EN

Playback starts YouTube’s embedded player (privacy-enhanced mode).

How to Create a Tic Tac Toe Game in Java NetBeans

144,008 views November 11, 2017 38:39

Watch on YouTube
ChannelDJ Oamen

Description from the creator

Create a TicTacToe games in Java NetBeans using Methods, call to methods, if statement, JFrame, jButtons, jPanels, jLabels and setting panels properties.

To support more videos from DJ Oamen, visit POamen Paypal
paypal.me/POamen

To Become a Channel member click on the Link below to JOIN:
youtube.com/channel/UCFtw9CfTfMKU9aHZsT2teYg/jo…

Winning Solution for Player O below:

if (b1==("O") && b2 == ("O") && b3 == ("O"))
{
JOptionPane.showMessageDialog(this,"Player O Wins", "Tic Tac Toe",JOptionPane.INFORMATION_MESSAGE);
oCounter++;
gameScore();
jButton1.setBackground(Color.PINK);
jButton2.setBackground(Color.PINK);
jButton3.setBackground(Color.PINK);
}

if (b4==("O") && b5 == ("O") && b6 == ("O"))
{
JOptionPane.showMessageDialog(this,"Player O Wins", "Tic Tac Toe",JOptionPane.INFORMATION_MESSAGE);
oCounter++;
gameScore();
jButton4.setBackground(Color.YELLOW);
jButton5.setBackground(Color.YELLOW);
jButton6.setBackground(Color.YELLOW);
}

if (b7==("O") && b8 == ("O") && b9 == ("O"))
{
JOptionPane.showMessageDialog(this,"Player O Wins", "Tic Tac Toe",JOptionPane.INFORMATION_MESSAGE);
oCounter++;
gameScore();
jButton7.setBackground(Color.MAGENTA);
jButton8.setBackground(Color.MAGENTA);
jButton9.setBackground(Color.MAGENTA);
}

if (b1==("O") && b4 == ("O") && b7 == ("O"))
{
JOptionPane.showMessageDialog(this,"Player O Wins", "Tic Tac Toe",JOptionPane.INFORMATION_MESSAGE);
oCounter++;
gameScore();

jButton1.setBackground(Color.MAGENTA);
jButton4.setBackground(Color.MAGENTA);
jButton7.setBackground(Color.MAGENTA);
}

if (b2==("O") && b5 == ("O") && b8 == ("O"))
{
JOptionPane.showMessageDialog(this,"Player O Wins", "Tic Tac Toe",JOptionPane.INFORMATION_MESSAGE);
oCounter++;
gameScore();
jButton2.setBackground(Color.MAGENTA);
jButton5.setBackground(Color.MAGENTA);
jButton8.setBackground(Color.MAGENTA);
}

if (b3==("O") && b6 == ("O") && b9 == ("O"))
{
JOptionPane.showMessageDialog(this,"Player O Wins", "Tic Tac Toe",JOptionPane.INFORMATION_MESSAGE);
oCounter++;
gameScore();
jButton3.setBackground(Color.PINK);
jButton6.setBackground(Color.PINK);
jButton9.setBackground(Color.PINK);
}

if (b1==("O") && b5 == ("O") && b9 == ("O"))
{
JOptionPane.showMessageDialog(this,"Player O Wins", "Tic Tac Toe",JOptionPane.INFORMATION_MESSAGE);
oCounter++;
gameScore();
jButton1.setBackground(Color.PINK);
jButton5.setBackground(Color.PINK);
jButton9.setBackground(Color.PINK);
}

if (b3==("O") && b5 == ("O") && b7 == ("O"))
{
JOptionPane.showMessageDialog(this,"Player O Wins", "Tic Tac Toe",JOptionPane.INFORMATION_MESSAGE);
oCounter++;
gameScore();
jButton3.setBackground(Color.PINK);
jButton5.setBackground(Color.PINK);
jButton7.setBackground(Color.PINK);
}

About this tutorial

DJ Oamen published this 38:39 video tutorial on November 11, 2017. It has been watched 144,008 times on YouTube.

Channel
DJ Oamen
Category
Education
Duration
38:39
Published
November 11, 2017
Views
144,008
Likes
1,381

Tags

Share

This tutorial in other languages