Bangladesh Train Tracker is a graphical train-tracking application that allows users to select a train and view its route information, schedule, current progress, next station, remaining distance and operating day
- 🚉 Select a train from a dropdown menu
- 🔎 Search trains using their train number/name
- 📋 Display detailed information for the selected train
- ⚡ Automatically update the interface whenever a different train is selected
| Train No. | Train Name | Route |
|---|---|---|
| 756 | Madhumati Express | Rajshahi → Dhaka |
| 792 | Banalata Express | Chapainawabganj → Dhaka |
| 754 | Silkcity Express | Rajshahi → Dhaka |
| 760 | Padma Express | Rajshahi → Dhaka |
For the selected train, the application displays:
- 🚉 Train Number
- 🏷️ Train Name
- 🚉 Start Station
- 🕐 Time of Departure
- 🏁 Destination Station
- 🕐 Time of Arrival
- 🛑 Number of Stops
- 📍 Next Station
- 🚉 Next Stop
- 📏 Total Distance
The information is displayed dynamically on the right side of the application window
The application includes a custom graphical route tracker:
- 🟢 Green stops → Stations already travelled
- 🔴 Red stops → Stations yet to be travelled
- 🟡 Yellow line → Approximate distance already travelled
- 📊 Progress is calculated from the number of passed stops
- 🚉 Every train has its own number of stations/stops
The tracker is implemented using a custom JPanel and Java's Graphics2D rendering system
The application displays the remaining journey information for the selected train. For example: Remaining 126 km in 02:50 hours
This provides an approximate indication of:
- 📏 Remaining distance
- ⏱️ Remaining journey time
The application automatically extracts the current day from the system and compares it with the train's scheduled off day. If the selected train is not operating on the current day: TRAIN OFF DAY: SUNDAY. The application also displays: Not Operating Today and resets the route progress tracker
Train information is stored permanently in: train-data.txt
The application:
- 📖 Reads train information from the file at startup
- 💾 Creates default train data if the file does not exist
- 📝 Saves train information back to the file
- 🔄 Loads the saved information whenever the application starts
| Category | Technology | Purpose |
|---|---|---|
| 💻 Core Language | Java | Implements the complete application logic |
| 🎨 GUI Framework | Java Swing | Creates the desktop graphical interface |
| 🧩 OOP | Classes & Objects | Models trains and stations |
| 🏛️ Abstraction | Abstract Class | Provides the RailwayEntity base class |
| 🔌 Interface | ITrainTracker |
Defines the UI update contract |
| 🧬 Inheritance | Train extends RailwayEntity |
Demonstrates class inheritance |
| 🗂️ Collections | ArrayList |
Stores train stations |
| 🗺️ Collections | HashMap |
Stores and retrieves train objects |
| 📁 File Handling | FileReader, FileWriter |
Reads/writes train-data.txt |
| 📖 Buffered I/O | BufferedReader, PrintWriter |
Efficient file reading/writing |
| 📅 Date Handling | LocalDate |
Extracts the current system date/day |
| 🕐 Date Formatting | TextStyle, Locale |
Converts system day into readable form |
| 🎨 Graphics | Graphics2D |
Draws the train progress tracker |
| 🖼️ Image Handling | ImageIcon |
Loads government and railway logos |
try-catch |
Handles file and data-processing errors |
The project was designed using multiple OOP concepts as required by the assignment.
abstract class RailwayEntity - The abstract class contains common railway entity information and defines: public abstract String getEntityType();. The Train class inherits from this class.
class Station - Represents an individual railway station. Each station contains: String name;
class Train extends RailwayEntity - Represents a complete train and stores information such as:
- Train number
- Train name
- Starting station
- Departure time
- Destination
- Arrival time
- Total distance
- Off day
- Passed stops
- Next station
- Next stop
- Remaining journey information
- List of stations
The class also provides: toFileString() to convert train information into the format used by train-data.txt
interface ITrainTracker - Defines the method: void updateUIContent();. The main application implements this interface so that the user interface can be dynamically updated whenever a train is selected
When the application starts, the main window displays:
The interface contains:
- 🚉 Train selection dropdown
- 🏛️ Government logo
- 🚂 Bangladesh Railway logo
- 📋 Train information panel
- 📊 Train progress tracker
- 📏 Remaining journey information
- 👨🏻💻 Student/project information
The user can select one of the available trains from the dropdown:
Select Train
756-Madhumati Express
792-Banalata Express
754-Silkcity Express
760-Padma Express
Whenever the selection changes, the displayed information is automatically updated
For example, selecting Silkcity Express displays:
1. Train Number: 754
2. Train Name: Silkcity Express
3. Start Station: Rajshahi
4. Time of Departure: 07:40
5. Destination Station: Dhaka
6. Time of Arrival: 13:20
7. Number of Stops: 13
8. Next Station: Ullapara
9. Next Stop: Jamtail
10. Total Distance: 220 km
The exact values are loaded from the train data
The bottom section displays the train's journey progress. Example:
●────●────●────●────●────●────●────●────●
🟢 🟢 🟢 🟢 🟢 🟢 🟢 🔴 🔴
The yellow portion represents the approximate travelled portion of the route. The application dynamically determines: Passed Stops and Total Stops, and paints the route accordingly
The application compares the train's configured off day with the current system day. For example, if a train's off day is Sunday and the system day is Sunday:
TRAIN OFF DAY: SUNDAY
Not Operating Today
When the train is operating, the bottom of the information panel displays information such as Remaining 126 km in 02:50 hours
Start: Rajshahi
Departure: 06:40
Destination: Dhaka
Arrival: 14:00
Distance: 220 km
Off Day: Saturday
Passed Stops: 5
Next Station: Poradaha
Next Stop: Kushtia Court
Start: Chapainawabganj
Departure: 06:00
Destination: Dhaka
Arrival: 11:35
Distance: 320 km
Off Day: Friday
Passed Stops: 1
Next Station: Rajshahi
Next Stop: Dhaka
Start: Rajshahi
Departure: 07:40
Destination: Dhaka
Arrival: 13:20
Distance: 220 km
Off Day: Sunday
Passed Stops: 7
Next Station: Ullapara
Next Stop: Jamtail
Start: Rajshahi
Departure: 16:00
Destination: Dhaka
Arrival: 21:15
Distance: 220 km
Off Day: Tuesday
Passed Stops: 5
Next Station: Ullapara
Next Stop: SHM Monsur Ali
/
├── main.java # Main Java application
├── assets/
| ├── train-tracker.png # Application interface
├── train-data.txt # Persistent train information
├── govtLogo.png # Government logo
├── railwayLogo.png # Bangladesh Railway logo
└── README.md # Project documentation
The application stores train information using the following format:
ID | Name | Start Station | Dep | Dest | Arr | Dist | Off Day | # | Next St. | Next Sp. | Progress Info | Stops
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
792 | Banalata Express | Chapainawabganj | 06:00 | Dhaka | 11:35 | 320 km | Friday | 1 | Rajshahi | Dhaka | Remaining 280 km in 04:45 hours | 3
754 | Silkcity Express | Rajshahi | 07:40 | Dhaka | 13:20 | 220 km | Sunday | 7 | Ullapara | Jamtail | Remaining 126 km in 02:50 hours | 13
760 | Padma Express | Rajshahi | 16:00 | Dhaka | 21:15 | 220 km | Tuesday | 5 | Ullapara | SHM Monsur Ali | Remaining 145 km in 03:20 hours | 12
756 | Madhumati Express | Rajshahi | 06:40 | Dhaka | 14:00 | 220 km | Saturday | 5 | Poradaha | Kushtia Court | Remaining 170 km in 05:10 hours | 23