Free

Billing System with Swing

Swing has exactly one thread allowed to touch the screen, and this shows you what ignoring it costs.

  • Java
  • Swing
  • BigDecimal

About this project

A desktop point-of-sale window: add items with a rate and quantity, edit or remove lines, apply GST at multiple slabs, apply a discount, and print a formatted invoice. Plain Java with javac and java — no Maven, no Gradle, no library.

The idea it is built around is that Swing has exactly one thread allowed to touch the interface, and almost every broken Swing project breaks that rule. The window is built on the Event Dispatch Thread, every update stays on it, and slow work goes to a SwingWorker. Rather than assert this, the project measures it: run it with --edt and it prints, in milliseconds, what happens when a listener does its work in place — including the moment where setText("Loading...") is called and never appears on screen, because the repaint is queued behind the very listener that is still running.

The second theme is money. GST at 18% on Rs 249.50 has to be right to the paisa, so amounts are BigDecimal with an explicit scale and rounding rule, and the project is explicit that taxing each line separately and taxing each rate slab as a whole give different totals on the same bill.

What you will learn

  • Keep every UI change on the Event Dispatch Thread, and move slow work off it with SwingWorker
  • Measure what a blocked UI thread actually does, rather than being told it is bad practice
  • Drive a JTable from a proper TableModel instead of rebuilding labels
  • Compute GST with BigDecimal and decide, deliberately, where the rounding happens
  • See why per-line and per-slab tax give different answers on the same bill

Before you start

  • Java basics — classes, interfaces, generics and exceptions
  • JDK 17 or newer. No build tool, no library.

New to Java? The free Java course covers everything this project assumes.

Academic integrity notice

These projects are provided for learning, experimentation and reference. Understand the code, modify it for your own requirements, and acknowledge external work according to your institution’s academic policies. Priodemy does not supply work to be submitted as your own.