

{"id":97024,"date":"2021-06-10T12:39:00","date_gmt":"2021-06-10T07:09:00","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=97024"},"modified":"2026-06-01T14:23:01","modified_gmt":"2026-06-01T08:53:01","slug":"java-tic-tac-toe-game","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/java-tic-tac-toe-game\/","title":{"rendered":"Tic Tac Toe Game in Java  [source code included]"},"content":{"rendered":"<p>Tic-Tac-Toe is a simple classic famous game which is played mostly by kids. The java tic tac toe game also helps to improve the concentration of the kids.<\/p>\n<p>The objective of this tic-tac-toe game java project is to build a tic-tac-toe game so anyone can play it without wasting paper. The Tic-Tac-Toe game is also called the X and O game. The player who succeeds in placing their marks in a diagonal, horizontal, or vertical row is the winner.<\/p>\n<h3>Java Tic Tac Toe \u2013 Project Details<\/h3>\n<p>The interesting java project will be build using the AWT and Swings libraries. We will be explaining all the steps as well as methods that are used in this project. Swings is a popular java library that is used to develop beautiful GUI applications.<\/p>\n<h3>Tic Tac Toe Project Prerequisites:<\/h3>\n<ul>\n<li>IDE Used: NetBeans 11.2.<\/li>\n<li>Java should be installed on the machine.<\/li>\n<li>To build a tic-tac-toe game using java we require basic knowledge of java.<\/li>\n<li>Abstract Window Toolkit (AWT) &amp; Swing packages are standard graphical user interfaces used to render graphics. By default, these packages are installed by java.<\/li>\n<\/ul>\n<h3>Download Tic Tac Toe Project Code<\/h3>\n<p>Please download the full source code of tic-tac-toe java project: <a href=\"https:\/\/drive.google.com\/file\/d\/1imklvckCfCYpSVex5IPCjMllWiowGbQk\/view?usp=drive_link\"><strong>Tic Tac Toe Java Project<\/strong><\/a><\/p>\n<h3>Step to build Tic-Tac-Toe game using java:<\/h3>\n<ol>\n<li>Import packages<\/li>\n<li>Initialize User Interface<\/li>\n<li>Adding Actions to buttons<\/li>\n<li>Function to check the winner<\/li>\n<\/ol>\n<h4>1. Import packages<\/h4>\n<p>In this step, we will import AWT &amp; Swing required packages<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import java.awt.BorderLayout;\r\nimport java.awt.Color;\r\nimport java.awt.FlowLayout;\r\nimport java.awt.GridLayout;\r\nimport java.awt.Image;\r\nimport java.awt.Label;\r\nimport java.awt.Toolkit;\r\nimport java.awt.event.ActionEvent;\r\nimport java.awt.event.ActionListener;\r\n\r\nimport javax.swing.BorderFactory;\r\nimport javax.swing.JButton;\r\nimport javax.swing.JFrame;\r\nimport javax.swing.JPanel;\r\n<\/pre>\n<h4>2. Initialize User Interface:<\/h4>\n<p>In this step, we basically create the user interface (UI) of our tic-tac-toe game, for that we use frames, panels, buttons, labels, etc.<\/p>\n<p><strong>Functions Definitions:<\/strong><\/p>\n<ul>\n<li><strong>setBackground(new Color(255,255,255)):<\/strong> This function will set the background color of the UI component.<\/li>\n<li><strong>setLayout(layout):<\/strong> This function will set the layout of the frame or panel. Layout can be grid, flow, gridbag, etc<\/li>\n<li><strong>setText(\u201cyour text\u201d):<\/strong> This function will set the text of the label, button, etc<\/li>\n<li><strong>setVisible(true):<\/strong> This function will set the frame\/window to be visible to the user. By default, it is false.<\/li>\n<li><strong>setBorder(BorderFactory.createLineBorder(Color.decode(&#8220;#2C6791&#8221;))):<\/strong> This function will set the border around the buttons, frames, panels, etc.<\/li>\n<li><strong>setSize(int width, int height):<\/strong> This function is used to set the size of frame, panel, etc. It takes two parameters such as width and height.<\/li>\n<li><strong>setIconImage(icon):<\/strong> This function is used to set the icon of the frame\/window.<\/li>\n<li><strong>add(obj):<\/strong> This function is used to add the component object in frame or panel.<\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\"> private void initUI(){\r\n          \r\n   \/\/Setting up panels layout\r\n   \/\/Creating 3*3=9 grid for game\r\n   board.setLayout(new GridLayout(3,3));\r\n   \/\/panel layout for printing winner of game\r\n   panel.setLayout(new FlowLayout());\r\n\r\n   \/\/Setting up buttons background color\r\n   btn1.setBackground(new Color(255,255,255));\r\n   btn2.setBackground(new Color(255,255,255));\r\n   btn3.setBackground(new Color(255,255,255));\r\n   btn4.setBackground(new Color(255,255,255));\r\n   btn5.setBackground(new Color(255,255,255));\r\n   btn6.setBackground(new Color(255,255,255));\r\n   btn7.setBackground(new Color(255,255,255));\r\n   btn8.setBackground(new Color(255,255,255));\r\n   btn9.setBackground(new Color(255,255,255));\r\n   btn10.setBackground(new Color(255,255,255));\r\n   \r\n    \/\/Setting up panel background color\r\n   panel.setBackground(new Color(255,255,255));\r\n   \r\n   \/\/Setting up button label text\r\n   btn10.setText(\"RESET\");\r\n   \r\n   \/\/Setting up buttons border\r\n   btn1.setBorder(BorderFactory.createLineBorder(Color.decode(\"#2C6791\")));\r\n   btn2.setBorder(BorderFactory.createLineBorder(Color.decode(\"#2C6791\")));\r\n   btn3.setBorder(BorderFactory.createLineBorder(Color.decode(\"#2C6791\")));\r\n   btn4.setBorder(BorderFactory.createLineBorder(Color.decode(\"#2C6791\")));\r\n   btn5.setBorder(BorderFactory.createLineBorder(Color.decode(\"#2C6791\")));\r\n   btn6.setBorder(BorderFactory.createLineBorder(Color.decode(\"#2C6791\")));\r\n   btn7.setBorder(BorderFactory.createLineBorder(Color.decode(\"#2C6791\")));\r\n   btn8.setBorder(BorderFactory.createLineBorder(Color.decode(\"#2C6791\")));\r\n   btn9.setBorder(BorderFactory.createLineBorder(Color.decode(\"#2C6791\")));\r\n\r\n   \/\/Adding all buttons in board layout\r\n   board.add(btn1);\r\n   board.add(btn2);\r\n   board.add(btn3);\r\n   board.add(btn4);\r\n   board.add(btn5);\r\n   board.add(btn6);\r\n   board.add(btn7);\r\n   board.add(btn8);\r\n   board.add(btn9);\r\n   \r\n   panel.add(btn10);\r\n   panel.add(lbl);\r\n   \r\n   \/\/Frame is parent of all every panel\r\n   \/\/panels are added in frame\r\n   f.add(board,BorderLayout.CENTER);\r\n   f.add(panel,BorderLayout.SOUTH);\r\n   \r\n   \/\/Setting up icon for frame\r\n   f.setIconImage(icon);    \r\n   \r\n   f.setVisible(true);\r\n   f.setSize(550,550);\r\n   f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\r\n\r\n}<\/pre>\n<h4>3. Adding Actions to buttons:<\/h4>\n<ul>\n<li>In this step, we will put actions to each button. We will specify what will happen when a button is clicked.<\/li>\n<li>In our scenario, when Player X presses a button on the grid, \u201cX\u201d will be printed and that button will be disabled for Player \u201cO\u201d.<\/li>\n<li>Similarly, when Player O presses a button on the grid, \u201cO\u201d will be printed and that button will be disabled for Player \u201cX\u201d.<\/li>\n<li>If a \u201cRESET\u2018 Button was clicked then the whole grid board will be cleared.<\/li>\n<\/ul>\n<p><strong>Adding actions on button code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\"> public void addActionEvents() {\r\n \r\n   \/\/registering action listener to buttons\r\n   \/\/Adding action listener for what will happen when player clicks on buttons\r\n   btn1.addActionListener(this);\r\n   btn2.addActionListener(this);\r\n   btn3.addActionListener(this);\r\n   btn4.addActionListener(this);\r\n   btn5.addActionListener(this);\r\n   btn6.addActionListener(this);\r\n   btn7.addActionListener(this);\r\n   btn8.addActionListener(this);\r\n   btn9.addActionListener(this);\r\n   btn10.addActionListener(this);\r\n      \r\n}<\/pre>\n<p><strong>Performing actions on click of button Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">@Override\r\npublic void actionPerformed(ActionEvent a) {\r\n  count++;\r\n  if(count == 1 || count == 3 || count == 5 || count == 7 || count == 9){\r\n    letter = \"X\";\r\n  } else if(count == 2 || count == 4 || count == 6 || count == 8 ){\r\n    letter = \"O\";\r\n  }\r\n\r\n  if(a.getSource() == btn1){\r\n    btn1.setText(letter);\r\n    btn1.setEnabled(false);\r\n  }else if(a.getSource() == btn2){\r\n    btn2.setText(letter);\r\n    btn2.setEnabled(false);\r\n  } else if(a.getSource() == btn3){\r\n    btn3.setText(letter);\r\n    btn3.setEnabled(false);\r\n  } else if(a.getSource() == btn4){\r\n    btn4.setEnabled(false);\r\n    btn4.setText(letter);\r\n  } else if(a.getSource() == btn5){\r\n    btn5.setText(letter);\r\n    btn5.setEnabled(false);\r\n  } else if(a.getSource() == btn6){\r\n    btn6.setText(letter);\r\n    btn6.setEnabled(false);\r\n  } else if(a.getSource() == btn7){\r\n    btn7.setEnabled(false);\r\n    btn7.setText(letter);\r\n  } else if(a.getSource() == btn8){\r\n    btn8.setEnabled(false);\r\n    btn8.setText(letter);\r\n  } else if(a.getSource() == btn9){\r\n    btn9.setText(letter);\r\n    btn9.setEnabled(false);\r\n  }\r\n  else if(a.getSource() == btn10){\r\n      \r\n    \/\/btn10 is for reset\r\n    \/\/Re-setting whole game\r\n    \r\n    letter = \"\";\r\n    count = 0;\r\n     \r\n    btn1.setEnabled(true);\r\n    btn2.setEnabled(true);\r\n    btn3.setEnabled(true);\r\n    btn4.setEnabled(true); \r\n    btn5.setEnabled(true);\r\n    btn6.setEnabled(true);\r\n    btn7.setEnabled(true);\r\n    btn8.setEnabled(true);\r\n    btn9.setEnabled(true);\r\n    \r\n    btn1.setText(\"\");\r\n    btn2.setText(\"\");\r\n    btn3.setText(\"\");\r\n    btn4.setText(\"\");\r\n    btn5.setText(\"\");\r\n    btn6.setText(\"\");\r\n    btn7.setText(\"\");\r\n    btn8.setText(\"\");\r\n    btn9.setText(\"\");\r\n    btn9.setText(\"\");\r\n\r\n    lbl.setText(\"\");\r\n    \r\n    win = false;\r\n  \r\n  }\r\n\r\n  \/\/Calling checkWinner() method for to check who is the winner\r\n  checkWinner();\r\n}<\/pre>\n<h4>4. Function to check the winner:<\/h4>\n<p>In this step, we basically check who is the winner of the game.<\/p>\n<p>For that we must know what are the rules of the winning of the game:<\/p>\n<ul>\n<li>If Player X or Player O cuts the grid in vertically , horizontally &amp; diagonally then that player will win the game.<\/li>\n<li>So, the 3 x 3 by grid has 8 combinations that can win the game.<\/li>\n<li>Vertically: {{1,2,3},{4,5,6},{7,8,9}}<\/li>\n<li>Horizontally: {{1,4,7},{2,5,8},{3,6,9}}<\/li>\n<li>Diagonally: {{1,5,9},{3,5,7}}<\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">private void checkWinner() {\r\n  \/\/Checking every condition of tic-tac-toe game\r\n  \/\/Check Horizontally\r\n  if (btn1.getText() == btn2.getText() &amp;&amp; btn2.getText() == btn3.getText() &amp;&amp; btn1.getText() != \"\" &amp;&amp; btn2.getText() != \"\" &amp;&amp; btn3.getText() != \"\") {\r\n    win = true;\r\n  }\r\n\r\n  \/\/Check Horizontally\r\n  else if (btn4.getText() == btn5.getText() &amp;&amp; btn5.getText() == btn6.getText() &amp;&amp; btn4.getText() != \"\" &amp;&amp; btn5.getText() != \"\" &amp;&amp; btn6.getText() != \"\") {\r\n    win = true;\r\n  }\r\n\r\n  \/\/Check Horizontally\r\n  else if (btn7.getText() == btn8.getText() &amp;&amp; btn8.getText() == btn9.getText() &amp;&amp; btn7.getText() != \"\" &amp;&amp; btn8.getText() != \"\" &amp;&amp; btn9.getText() != \"\") {\r\n    win = true;\r\n  }\r\n\r\n  \/\/Check Vertically\r\n  else if (btn1.getText() == btn4.getText() &amp;&amp; btn4.getText() == btn7.getText() &amp;&amp; btn1.getText() != \"\" &amp;&amp; btn4.getText() != \"\" &amp;&amp; btn7.getText() != \"\") {\r\n    win = true;\r\n  }\r\n\r\n  \/\/Check Vertically\r\n  else if (btn2.getText() == btn5.getText() &amp;&amp; btn5.getText() == btn8.getText() &amp;&amp; btn2.getText() != \"\" &amp;&amp; btn5.getText() != \"\" &amp;&amp; btn8.getText() != \"\") {\r\n    win = true;\r\n  } else if (btn3.getText() == btn6.getText() &amp;&amp; btn6.getText() == btn9.getText() &amp;&amp; btn3.getText() != \"\" &amp;&amp; btn6.getText() != \"\" &amp;&amp; btn9.getText() != \"\") {\r\n    win = true;\r\n  }\r\n\r\n  \/\/Check Diagonally\r\n  else if (btn1.getText() == btn5.getText() &amp;&amp; btn5.getText() == btn9.getText() &amp;&amp; btn1.getText() != \"\" &amp;&amp; btn5.getText() != \"\" &amp;&amp; btn9.getText() != \"\") {\r\n    win = true;\r\n  }\r\n\r\n  \/\/Check Diagonally\r\n  else if (btn3.getText() == btn5.getText() &amp;&amp; btn5.getText() == btn7.getText() &amp;&amp; btn3.getText() != \"\" &amp;&amp; btn5.getText() != \"\" &amp;&amp; btn7.getText() != \"\") {\r\n    win = true;\r\n  } else {\r\n    win = false;\r\n  }\r\n\r\n  if (win) {\r\n    lbl.setText(\"Hurray! Player \" + letter + \" wins!\");\r\n    btn1.setEnabled(false);\r\n    btn2.setEnabled(false);\r\n    btn3.setEnabled(false);\r\n    btn4.setEnabled(false);\r\n    btn5.setEnabled(false);\r\n    btn6.setEnabled(false);\r\n    btn7.setEnabled(false);\r\n    btn8.setEnabled(false);\r\n    btn9.setEnabled(false);\r\n\r\n  } else if (!win &amp;&amp; count == 9) {\r\n    lbl.setText(\"The game ended in a tie.\");\r\n    btn1.setEnabled(false);\r\n    btn2.setEnabled(false);\r\n    btn3.setEnabled(false);\r\n    btn4.setEnabled(false);\r\n    btn5.setEnabled(false);\r\n    btn6.setEnabled(false);\r\n    btn7.setEnabled(false);\r\n    btn8.setEnabled(false);\r\n    btn9.setEnabled(false);\r\n  }\r\n}<\/pre>\n<h3>Java Tic Tac Toe Output<\/h3>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/tic-tac-toe-java-output.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-97226\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/tic-tac-toe-java-output.png\" alt=\"tic tac toe java output\" width=\"1024\" height=\"540\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/tic-tac-toe-java-output.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/tic-tac-toe-java-output-300x158.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/tic-tac-toe-java-output-150x79.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/tic-tac-toe-java-output-768x405.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/tic-tac-toe-java-output-720x380.png 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/tic-tac-toe-java-output-520x274.png 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/tic-tac-toe-java-output-320x169.png 320w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/p>\n<h3>Summary<\/h3>\n<p>Yay! we have successfully developed a simple tic tac toe game in java!<\/p>\n<p>In this tic-tac-toe java project we learned: how to create a basic game and also we saw how to create user interface components such as frames, panels, buttons, labels, etc with the help of AWT and Swing packages.<span hidden class=\"__iawmlf-post-loop-links\" data-iawmlf-links=\"[{&quot;id&quot;:2616,&quot;href&quot;:&quot;https:\\\/\\\/drive.google.com\\\/file\\\/d\\\/1imklvckCfCYpSVex5IPCjMllWiowGbQk\\\/view?usp=drive_link&quot;,&quot;archived_href&quot;:&quot;http:\\\/\\\/web-wp.archive.org\\\/web\\\/20260601085435\\\/https:\\\/\\\/drive.google.com\\\/file\\\/d\\\/1imklvckCfCYpSVex5IPCjMllWiowGbQk\\\/view?usp=drive_link&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-06-02 08:37:13&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-14 12:10:47&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-18 03:44:04&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-22 10:07:05&quot;,&quot;http_code&quot;:200}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-06-22 10:07:05&quot;,&quot;http_code&quot;:200},&quot;process&quot;:&quot;done&quot;}]\"><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Tic-Tac-Toe is a simple classic famous game which is played mostly by kids. The java tic tac toe game also helps to improve the concentration of the kids. The objective of this tic-tac-toe game&#46;&#46;&#46;<\/p>\n","protected":false},"author":5,"featured_media":97217,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32],"tags":[22479,22475,24583],"class_list":["post-97024","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","tag-java-project","tag-tic-tac-toe-game","tag-tic-tac-toe-java"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Tic Tac Toe Game in Java [source code included] - DataFlair<\/title>\n<meta name=\"description\" content=\"Create a simple tic tac toe game in java. We developed simple java project with gui using AWT, Swings and other basic concepts\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/java-tic-tac-toe-game\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Tic Tac Toe Game in Java [source code included] - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Create a simple tic tac toe game in java. We developed simple java project with gui using AWT, Swings and other basic concepts\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/java-tic-tac-toe-game\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-06-10T07:09:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-06-01T08:53:01+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/java-project-tic-tac-toe-game.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Tic Tac Toe Game in Java [source code included] - DataFlair","description":"Create a simple tic tac toe game in java. We developed simple java project with gui using AWT, Swings and other basic concepts","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/java-tic-tac-toe-game\/","og_locale":"en_US","og_type":"article","og_title":"Tic Tac Toe Game in Java [source code included] - DataFlair","og_description":"Create a simple tic tac toe game in java. We developed simple java project with gui using AWT, Swings and other basic concepts","og_url":"https:\/\/data-flair.training\/blogs\/java-tic-tac-toe-game\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2021-06-10T07:09:00+00:00","article_modified_time":"2026-06-01T08:53:01+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/java-project-tic-tac-toe-game.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/java-tic-tac-toe-game\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/java-tic-tac-toe-game\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823"},"headline":"Tic Tac Toe Game in Java [source code included]","datePublished":"2021-06-10T07:09:00+00:00","dateModified":"2026-06-01T08:53:01+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/java-tic-tac-toe-game\/"},"wordCount":639,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/java-tic-tac-toe-game\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/java-project-tic-tac-toe-game.jpg","keywords":["java project","tic tac toe game","tic tac toe java"],"articleSection":["Java Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/java-tic-tac-toe-game\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/java-tic-tac-toe-game\/","url":"https:\/\/data-flair.training\/blogs\/java-tic-tac-toe-game\/","name":"Tic Tac Toe Game in Java [source code included] - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/java-tic-tac-toe-game\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/java-tic-tac-toe-game\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/java-project-tic-tac-toe-game.jpg","datePublished":"2021-06-10T07:09:00+00:00","dateModified":"2026-06-01T08:53:01+00:00","description":"Create a simple tic tac toe game in java. We developed simple java project with gui using AWT, Swings and other basic concepts","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/java-tic-tac-toe-game\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/java-tic-tac-toe-game\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/java-tic-tac-toe-game\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/java-project-tic-tac-toe-game.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/java-project-tic-tac-toe-game.jpg","width":1200,"height":628,"caption":"java project tic tac toe game"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/java-tic-tac-toe-game\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Java Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/java\/"},{"@type":"ListItem","position":3,"name":"Tic Tac Toe Game in Java [source code included]"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team creates expert-level guides on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our goal is to empower learners with easy-to-understand content. Explore our resources for career growth and practical learning.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam1\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/97024","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=97024"}],"version-history":[{"count":6,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/97024\/revisions"}],"predecessor-version":[{"id":148702,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/97024\/revisions\/148702"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/97217"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=97024"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=97024"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=97024"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}