Tic Tac Toe Game (Java Swing)
A simple GUI-based Tic Tac Toe game built with Java Swing.
This project lets two players play Tic Tac Toe on a 3x3 grid using a modern graphical interface.
Features
- Intuitive GUI: 3x3 grid built with Java Swing components.
- Two-player mode: Players alternate turns as ‘X’ and ‘O’.
- Winner Detection: Automatically checks for win or draw after every move.
- Board Reset: Automatically clears the board after each game.
- User-friendly prompts: Uses pop-up messages to announce the winner.
How to Run
-
Clone or download this repository.
(Click the green “Code” button > Download ZIP, or use git clone <repo-link>
)
-
Open the project folder in VS Code, IntelliJ, or any Java IDE.
-
Compile the code:
javac TicTacToeGame.java
- Run the program:
java TicTacToeGame
- Play the game:
- Players take turns clicking empty cells to mark them ‘X’ or ‘O’.
- The first player to align three marks in a row, column, or diagonal wins.
Project Structure
TicTacToeGame.java
– Main source code for the game logic and GUI.
Concepts and Technologies Used
- Java Swing GUI framework (
JFrame
, JButton
, JOptionPane
)
- Event-driven programming (
ActionListener
)
- 2D arrays for grid management
- Basic OOP principles
Feel free to star or fork this repository if you find it useful!