A simple yet fully functional BlackJack card game built using Java Swing with a graphical user interface. Players can hit or stay, and the dealer follows standard rules (hits until 17 or higher). The game supports Ace value adjustment (11 or 1) and displays win/loss/tie results.
- Full 52-card deck with suits: Clubs (C), Diamonds (D), Hearts (H), Spades (S)
- Card images for visual gameplay
- Dealer shows one card initially, hides the second
- "Hit" and "Stay" buttons
- Automatic Ace value reduction (
11 → 1) when busting - Win/Lose/Tie detection
- Clean UI with green felt background
- Card animations via
paintComponent
| You Win! | You Lose! | Dealer Hidden Card |
|---|---|---|
![]() |
![]() |
![]() |
BlackJack/
│
├── src/
│ ├── BlackJack.java # Main game logic and GUI
│ └── App.java # Entry point (main method)
│
├── assets/
│ └── cards/ # Card images (PNG)
│ ├── A-C.png
│ ├── 2-D.png
│ └── ... (52 cards + BACK.png)
│
└── README.md
Note: Card images must be placed in
assets/cards/with naming format:VALUE-SUIT.png(e.g.,A-H.png,10-S.png,K-C.png) andBACK.pngfor the card back.
- Open the project folder.
- Ensure
assets/cards/contains all 52 card images +BACK.png. - Run
App.java.
# Compile
javac -d bin src/*.java
# Run
java -cp bin AppMake sure the
assetsfolder is in the same directory asbinwhen running.
- Goal: Get as close to 21 without going over.
- Card Values:
2–10: Face valueJ, Q, K: 10A: 11 or 1 (automatically adjusted)
- Dealer: Hits on 16 or lower, stays on 17+
- Player Actions:
- Hit: Take another card
- Stay: End turn, dealer plays
- Java Swing (built-in)
- Java AWT
- Card images in
assets/cards/
No external libraries required.
- Custom
Cardclass withgetValue(),isAce(), and image path - Real-time UI updates using
repaint() - Proper Ace handling with
reducePlayerAce()andreduceDealerAce() - Resource loading via
getClass().getResource()
- Add "Play Again" button
- Display current hand totals
- Add sound effects
- Support splitting and doubling down
- Score tracking
- Animations for dealing cards
Your Name
Java Developer | Game Enthusiast
This project is open-source and free to use for educational purposes.
- Save this content as
README.mdin your project root. - Create a
screenshots/folder and add your three images:win.pnglose.pnghidden.png
- Create
assets/cards/and place all card PNGs there. - Done! Your project is now professionally documented.
Let me know if you want a GitHub-ready version with badges, GIF demo, or downloadable ZIP setup!


