Hello everyone! Today, I'm excited to share with you a Java project I've been working on. As a software developer, I often find it difficult to accurately track time spent on different projects. This problem is what inspired me to build Chronically – a time-tracking software developed in Java. In this blog post, I will share an overview of the software, its key features, and some snippets of its crucial bits of code. As usual, my code snippets will be wrapped in
tags to ensure clear readability. Chronically is a desktop software designed to serve a simple purpose - to provide a user-friendly platform for tracking time. It features an intuitive UI, where users can create different tasks and simply hit a 'start' button to begin recording time, and a 'stop' button when they're done. The software then logs this time against the task, allowing you to see exactly how long you spent on what. All of these are achieved using the Java Swing library for the GUI, and serialization for persistent data storage.//Task Start/Stop buttons private void startTimeTracking() { if (startTime == null) { startTime = new Date(); startStopButton.setText("Stop"); } else { finishTime(); } } private void finishTime() { long taskTime = new Date().getTime() - startTime.getTime(); currentTask.incrementTime(taskTime); startTime = null; startStopButton.setText("Start"); }The Chronically software also provides graphs for visual presentation of time spent on each task. These graphs are customizable, either showing break up of time spent over weeks, months, or individual days. This was achieved using JFreeChart, a popular Java library for creating a wide variety of highly customizable charts.
//Creating a Pie Chart private JFreeChart createPieChart() { DefaultPieDataset pieDataset = new DefaultPieDataset(); for (Task task : tasks) { pieDataset.setValue(task.getName(), task.getTime()); } JFreeChart chart = ChartFactory.createPieChart3D( "Task Timing", pieDataset, true, true, false ); return chart; }Moreover, the software provides notifications and reminders to assist in time management. Users can set up reminders for tasks from the software interface itself. I used the JavaFX library to handle this, given its powerful but easy-to-use tools for creating dialogs, pop-ups, and other types of notifications.
// Creating a reminder alert using JavaFX public void createReminder(Task task) { Timeline reminderTimeline = new Timeline(new KeyFrame( Duration.seconds(task.getReminderTime()), ae -> Platform.runLater(() -> { Alert reminderAlert = new Alert(AlertType.INFORMATION); reminderAlert.setTitle("Task Reminder"); reminderAlert.setHeaderText(null); reminderAlert.setContentText("Reminder: " + task.getName()); reminderAlert.showAndWait(); })) ); reminderTimeline.play(); }In conclusion, Chronically is an effortless, user-friendly, Java-based time-tracking software that addresses the issues often faced by many professionals (including myself). Not only does it accurately track time, but it also provides visual data and reminders to assist in managing it efficiently. Although I built Chronically as a personal project to solve my needs, I hope it might be useful to anyone needing a simple time-tracking system. Looking forward to seeing any feedback or suggestions you may have!