DEV Community

Cover image for Building My Own POS System in Java Swing - From UI to Database
dangkh0a
dangkh0a

Posted on

Building My Own POS System in Java Swing - From UI to Database

A comprehensive Point of Sale Management Application developed using Java Swing, based on the MVC + UI Layered architecture. The application includes fully functional modules for managing products, invoices, customers, employees, stock, and more โ€” designed with modularity and extensibility in mind.


๐Ÿงฐ Technologies & Development Environment

๐Ÿ”ง Component โš™๏ธ Details
๐Ÿ–ฅ๏ธ Language Java 24
๐Ÿง  IDE NetBeans 25 (Apache NetBeans)
๐ŸŽจ UI Toolkit Java Swing + FlatLaf
๐Ÿ—ƒ๏ธ Database MySQL + JDBC (mysql-connector-j)
๐Ÿงฉ Architecture DAO โ€“ Model โ€“ View โ€“ Component Separation (MVC++)
๐Ÿ–Œ๏ธ Theme FlatLaf Light

๐Ÿ’ป System Requirements

  • โ˜• Java JDK 17 or higher (Java 21+ recommended)
  • ๐Ÿ’ก NetBeans 15+ or IntelliJ with Swing support
  • ๐Ÿ›ข๏ธ MySQL Server 5.7+ or 8.x
  • ๐Ÿง‘โ€๐Ÿ’ป Compatible with Windows / macOS / Linux

๐Ÿ“ Project Structure

pos_app/
โ”œโ”€โ”€ dao/              # Data access layer (Database Access)
โ”œโ”€โ”€ icons/            # UI icons (SVG/PNG)
โ”œโ”€โ”€ models/           # Data models: Product, Invoice, Customer, ...
โ”œโ”€โ”€ pictures/         # Static images for UI
โ”œโ”€โ”€ sql/              # SQL files (schema & data)
โ”œโ”€โ”€ ui.components/    # Reusable UI components: Button, Sidebar, Header,...
โ”œโ”€โ”€ ui.dialog/        # Forms for data input/edit
โ”œโ”€โ”€ ui.panel/         # Feature panels: Products, Invoices...
โ”œโ”€โ”€ ui.table/         # Custom table renderers/editors
โ”œโ”€โ”€ util/             # Utilities: DBConnection, IconUtil, ...
โ”œโ”€โ”€ view/             # Main application frame (MainFrame.java)
โ””โ”€โ”€ test/             # Unit tests
Enter fullscreen mode Exit fullscreen mode

๐Ÿ“ฆ Dependencies

๐Ÿ“š Library ๐Ÿ“ Description
FlatLaf Modern look and feel, SVG support, IntelliJ/Dark mode
flatlaf-extras Easy theme/icon customization from SVG
darklaf-core (Optional) Shadow, blur effects
darklaf-utils, darklaf-property-loader Darklaf config utilities
mysql-connector-j MySQL JDBC connector
protobuf-java Fallback for binary data storage
jsvg Display SVG icons in UI
java-se (core-3.5.3, javase-3.5.3) Image/webcam/barcode processing
webcam-capture Webcam integration for scanning QR/barcodes or taking photos
slf4j-api, slf4j-simple Simple system logging
bridj Native Windows call for webcam
gson Convert between JSON and Java objects

๐Ÿ–ฅ๏ธ Main Features

๐Ÿงฉ Feature ๐Ÿ“Œ Description
๐Ÿ›’ Sales (POS) POS UI, cart management, payment processing, invoice printing
๐Ÿ“ฆ Product Management CRUD products, update quantity/price/status, category management
๐Ÿ‘ค Customer Manage customer info and grouping
๐Ÿงพ Invoice List, search, view and print invoices
๐Ÿ“Š Statistics Sales summary with Pie/Bar charts (in progress)
๐Ÿšš Stock In/Out Track inventory, create stock-in and stock-out slips
๐Ÿ‘” Employees/Roles Manage accounts, assign roles (Admin, Staff)
๐Ÿ“‹ Dashboard Aggregate system update logs from POS machines
โš™๏ธ System Settings Configure theme, store info, currency, etc.

โœ… Getting Started

  1. Clone the repository:
   git clone https://github.com/dangkhoa2004/pos_app.git
Enter fullscreen mode Exit fullscreen mode
  1. Open with IDE: ๐Ÿ‘‰ Preferably NetBeans 25 or IntelliJ (pre-configured with Maven/Ant)
  2. Setup MySQL database:
   CREATE DATABASE pos_app CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
Enter fullscreen mode Exit fullscreen mode

Then import pos_app.sql from the /sql folder.

  1. Configure DB in DBConnection.java:
   private static final String URL = "jdbc:mysql://localhost:3306/pos_app";
   private static final String USER = "root";
   private static final String PASSWORD = ""; // Change to your password
Enter fullscreen mode Exit fullscreen mode
  1. Run MainFrame.java to launch the application.
  2. Notes:
    • Add JDBC driver if ClassNotFoundException occurs
    • Use UTF-8 for proper Vietnamese character display

๐Ÿ“Œ Development Notes

  • All icons are in icons/ as scalable SVGs
  • To add new feature โ†’ Create Panel in ui.panel โ†’ Register via SideBarMenu
  • Under-construction features will show a JOptionPane message
  • The project is extensible: PDF invoice, cloud sync, etc. ready for integration

๐Ÿ“ธ UI Screenshots

๐ŸŒ™ FlatLaf Dark Mode

โณ Coming soon

โ˜€๏ธ FlatLaf Light Mode

โณ Coming soon

๐Ÿ”ฎ Roadmap

  • [ ] ๐Ÿงพ Export invoice to PDF
  • [ ] ๐Ÿ“ค Google Sheets API integration
  • [ ] ๐Ÿ’พ Scheduled automatic backups
  • [ ] ๐Ÿ” Advanced login & permission system
  • [ ] โ˜๏ธ Firebase cloud sync (optional)

๐Ÿค Contributing

We welcome contributions to improve this project!

  • ๐Ÿ›  Fork the repo
  • ๐ŸŒฑ Create a branch: feature/<feature-name>
  • ๐Ÿ“ฅ Submit a detailed Pull Request

๐Ÿ“š Technical Docs

  • ๐Ÿงฉ DB Schema & Sample Data:
CREATE DATABASE IF NOT EXISTS pos_app;
USE pos_app;

CREATE TABLE roles (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(50) NOT NULL
);

CREATE TABLE employees (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(100),
    username VARCHAR(50) UNIQUE,
    password VARCHAR(255),
    role_id INT,
    FOREIGN KEY (role_id) REFERENCES roles(id)
);

-- More tables...
Enter fullscreen mode Exit fullscreen mode

View full SQL file

  • ๐Ÿงฉ ER Diagram: DB Schema

๐Ÿ“œ License

This project is currently not published under an open license.

Please contact the author for permission if you'd like to use or redistribute the code.


๐Ÿ‘ค Author & Contact

Top comments (0)