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.
Features
- JTable driven by a real TableModel, with editable quantities
- Multiple GST slabs, CGST/SGST split, percentage discount and round-off
- Per-line or per-slab tax, switchable, with the difference shown
- A printed invoice view and a saved text file
- --proof mode: the money arithmetic, computed at runtime, with no window
- --edt mode: the cost of blocking the UI thread, measured in milliseconds
Technology stack
Track: Java · Level: Mini project
What is included
- Money.java, Item.java, Invoice.java and Billing.java — commented throughout
- A README on the Event Dispatch Thread, SwingWorker and GST rounding
- Suggested extensions, including persistence and a printable PDF
Delivered as a 42 KB ZIP. SHA-256 published under Changelog so you can verify it.
System requirements
- Operating system
- Windows, macOS or Linux with a desktop
- Runtime
- JDK 17 or newer. javac and java only.
Licence
Learn from it, change it, and use it in your own coursework and personal projects. Do not resell it or pass it off as your own original work.
- Personal and educational use
- Modifying the code however you like
- Using it as the basis of your own coursework, with honest acknowledgement
- Putting your modified version in a portfolio or on your own GitHub
- Reselling or redistributing the project, modified or not
- Presenting it as your own original work
- Commercial deployment — see the Commercial licence
Support window: 6 months from download.
Frequently asked
What actually goes wrong if I ignore the Event Dispatch Thread?
Run it with --edt and watch. The project runs the same work both ways and prints the timings: done on the UI thread, a status message set at 0 ms is never painted at all, because the repaint is an event queued behind the listener that set it. The window simply freezes and then shows the final state.
Why does the GST total change when I switch to per-line?
Because rounding happens more often. Taxing four lines separately rounds four times; taxing the slab as a whole rounds once. On the sample bill that is one paisa, and the totals panel shows both. Which one is correct depends on the rule you are invoicing under, which is why it is a setting and not a hard-coded choice.
Is this enough for a college mini project?
Yes, and Swing, the EDT and BigDecimal are all examinable. Understand the threading well enough to explain the --edt output, extend it, and write your own report.
Changelog
- First release
SHA-256ff9869bf103a325a9def52861d3f6de44b8b51719c0c4205e4da9808bb9e44e5