A classic Minesweeper game with both Swing and JavaFX implementations, featuring clean architecture, comprehensive testing, and modern Java development practices.
# Clone the repository
git clone https://github.com/UNC-GDSC/Minesweeper-Game.git
cd Minesweeper-Game
# Build the project
mvn clean package
# Run the JavaFX version
mvn javafx:run
# Or run the Swing version
java -jar target/minesweeper-swing.jar
Minesweeper-Game/
โโโ src/
โ โโโ main/
โ โ โโโ java/com/unc/gdsc/minesweeper/
โ โ โ โโโ core/ # Core game logic (UI-independent)
โ โ โ โ โโโ Cell.java # Cell model
โ โ โ โ โโโ GameBoard.java # Game board logic
โ โ โ โโโ swing/ # Swing implementation
โ โ โ โ โโโ MinesweeperSwing.java
โ โ โ โโโ javafx/ # JavaFX implementation
โ โ โ โโโ MinesweeperFXApp.java
โ โ โ โโโ StatusBarFX.java
โ โ โโโ resources/
โ โ โโโ styles.css # JavaFX CSS styling
โ โโโ test/
โ โโโ java/com/unc/gdsc/minesweeper/core/
โ โโโ CellTest.java # Cell unit tests
โ โโโ GameBoardTest.java # GameBoard unit tests
โโโ pom.xml # Maven configuration
โโโ .gitignore # Git ignore rules
โโโ LICENSE # MIT License
โโโ README.md # This file
โโโ CONTRIBUTING.md # Contribution guidelines
# Clean and compile
mvn clean compile
# Run tests
mvn test
# Package as JAR files
mvn package
# Generate JavaDoc
mvn javadoc:javadoc
After running mvn package, youโll find:
target/minesweeper-swing.jar - Standalone Swing versiontarget/minesweeper-javafx.jar - Standalone JavaFX versiontarget/minesweeper-2.0.0.jar - Main artifact# Using Maven plugin
mvn javafx:run
# Or using the JAR file
java -jar target/minesweeper-javafx.jar
Features:
# Using Maven exec plugin
mvn exec:java -P swing
# Or using the JAR file
java -jar target/minesweeper-swing.jar
Features:
Run the complete test suite:
mvn test
Run specific test class:
mvn test -Dtest=CellTest
mvn test -Dtest=GameBoardTest
Generate test coverage report (requires Jacoco plugin):
mvn jacoco:report
Both implementations use these default settings:
To customize, modify the constants in the respective main classes:
private static final int ROWS = 16;
private static final int COLS = 16;
private static final int MINES = 40;
com.unc.gdsc.minesweeper.core): Contains game logic independent of UI framework
Cell: Represents a single grid cellGameBoard: Manages game state, mine placement, and game rulesSwing Package (com.unc.gdsc.minesweeper.swing): Swing-based UI implementation
com.unc.gdsc.minesweeper.javafx): JavaFX-based UI implementation with enhanced featurescore packageswing or javafx packageThe project includes two Maven profiles:
# Run JavaFX version (default)
mvn exec:java -P javafx
# Run Swing version
mvn exec:java -P swing
Generate JavaDoc documentation:
mvn javadoc:javadoc
Documentation will be available in target/site/apidocs/index.html
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
git checkout -b feature/amazing-feature)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ UI Layer (Swing/JavaFX) โ
โ - Event handling โ
โ - Rendering โ
โ - User interaction โ
โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโ
โ
โ calls methods on
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Core Layer (Game Logic) โ
โ - Cell management โ
โ - Mine placement โ
โ - Win/loss detection โ
โ - Flood-fill algorithm โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
If you encounter JavaFX module errors:
# Ensure you're using Java 11+
java -version
# Use Maven to run (handles modules automatically)
mvn javafx:run
# Clean Maven cache
mvn clean
# Delete target directory
rm -rf target/
# Rebuild
mvn install
Developed by: UNC-CH Google Developer Student Club License: MIT License Year: 2025
This project is licensed under the MIT License - see the LICENSE file for details.
MIT License
Copyright (c) 2025 UNC-CH Google Developer Student Club
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction...
Happy Mining! ๐ฃ