Hit or stand, in Java Swing. A 2014 Eclipse project rebuilt on Java 17, with the dealer scoring bug finally fixed.
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Dixon D'Cunha f17bf70c0a
feat: modularize and fix game logic
Replaces the monolithic JFrame-based implementation with a clean
model/game/UI separation targeting Java 17.

Model (com.exikle.blackjack.model):
- Suit, Rank enums — ordinals map directly to cards.png sprite columns/rows
- Card record — immutable; exposes sprite coordinates and base value
- Deck — shuffled 52-card deck using Collections.shuffle

Game logic (BlackJackGame):
- State machine: IDLE → PLAYER_TURN → terminal state
- Correct ace soft/hard handling (11→1 when bust, per hand)
- Fix dealer-score bug from original (was summing player's offset cards)
- Clean win/bust/tie detection without duplicated conditions

UI (BlackJackFrame):
- SwingUtilities.invokeLater entry point; EXIT_ON_CLOSE added
- GamePanel inner class owns all drawing; reads from BlackJackGame
- Visual style preserved: felt table, maroon arc border, sprite-sheet cards,
  RoundedCornerButton controls

Remove: BlackJackMain, BlackJackGUI1, original/BlackJackOriginal (all superseded)
License: bump CC BY-NC-SA 3.0 → 4.0
2026-06-27 15:03:02 -04:00
res chore: preserve and clean up project for archival 2026-06-27 14:55:30 -04:00
src/com/exikle/blackjack feat: modularize and fix game logic 2026-06-27 15:03:02 -04:00
.gitignore chore: preserve and clean up project for archival 2026-06-27 14:55:30 -04:00
LICENSE feat: modularize and fix game logic 2026-06-27 15:03:02 -04:00
README.md feat: modularize and fix game logic 2026-06-27 15:03:02 -04:00

BlackJack

A Java Swing desktop implementation of Blackjack. Cards are rendered from a sprite sheet with a custom-drawn green felt table and rounded corner buttons.

Features

  • Single-player Blackjack against a dealer
  • Hit, Stand, and Deal actions
  • Correct ace soft/hard handling (11 → 1 when bust)
  • Dealer draws to hard 17
  • Win / lose / tie detection with bust handling

Project Structure

src/com/exikle/blackjack/
  model/
    Suit.java            — enum: HEARTS, DIAMONDS, SPADES, CLUBS
    Rank.java            — enum: ACE–KING, each with a point value
    Card.java            — immutable record; exposes sprite coordinates
    Deck.java            — 52-card shuffled deck
  BlackJackGame.java     — game logic and state machine (no Swing)
  BlackJackFrame.java    — Swing UI; main entry point
  RoundedCornerButton.java — custom JButton with rounded corners
res/
  cards.png              — sprite sheet (13 cols × 4 rows, 144×194 px per card)

How to Build and Run

Requirements

  • Java 17 or later

Compile

mkdir -p bin
javac -d bin -sourcepath src \
    src/com/exikle/blackjack/BlackJackFrame.java
cp res/cards.png bin/

Run

java -cp bin com.exikle.blackjack.BlackJackFrame

License

Copyright (c) 2014 Dixon D'Cunha.
Licensed under CC BY-NC-SA 4.0.