Skip to content

Latest commit

 

History

History
115 lines (87 loc) · 5.1 KB

File metadata and controls

115 lines (87 loc) · 5.1 KB

Task 6: Java GUI - To-Do App

Author: Mummana Devi Prasad
Project Role: Java Developer Intern Task


📌 Project Description

The Java GUI To-Do List Application is a lightweight, responsive desktop tool designed using the standard Java Swing library. It features a clean, professional user interface to organize tasks, enter new items, track totals, and delete completed activities.

This project is built to demonstrate intermediate Java concepts including event-driven programming, graphical component layout management, custom styling delegates, and proper thread handling using the Event Dispatch Thread (EDT).


✨ Features

  • Modern & Clean Styling: Leverages native Look-and-Feel support combined with indigo/crimson UI accents to present a clean visual experience.
  • Dynamic Task Display: Uses a dynamic list framework to display tasks with alternating zebra-striping colors and spacious row padding.
  • Fluent Addition & Deletion:
    • Enter text in the field and click Add Task or press Enter on the keyboard to submit.
    • Highlight any row item and click Delete Task to clear it.
  • Input Validation Safeguards: Generates warning dialog alerts if a user attempts to add a blank task or delete without highlighting a row.
  • Dynamic Counter: Monitors the exact number of active items in real-time.

🛠️ Technologies Used

  • Programming Language: Java (JDK 8 or higher)
  • GUI Toolkit: Java Swing (built-in)
  • Graphics & Event Handling: Java AWT (Abstract Window Toolkit)

💡 Key Concepts Explained

1. Java Swing Components

  • JFrame: The top-level window container hosting all user interface elements.
  • JTextField: A text-entry box that reads custom string descriptions.
  • JList<String>: Displays task arrays dynamically.
  • DefaultListModel<String>: Represents the underlying data model. Manipulating this model automatically updates the JList interface in real-time.
  • JScrollPane: Encompasses the JList structure to allow vertical scroll bars when items overflow the frame layout.

2. Event Handling (ActionListener)

  • Programmed with ActionListener interfaces mapping user triggers (clicking buttons or pressing Enter) to corresponding methods:
    • taskField.addActionListener(addTaskListener); (runs when the Enter key is pressed).
    • addButton.addActionListener(addTaskListener); (runs when the Add Task button is clicked).
    • deleteButton.addActionListener(...) (runs when the Delete Task button is clicked).

3. Layout Managers

  • BorderLayout: Structures the main frame with spacing (Header on top NORTH, Scrollable List in the CENTER, and Control inputs/status in the SOUTH).
  • BoxLayout: Organizes header text and input boxes sequentially along the vertical Y-axis.
  • GridLayout: Keeps the operational buttons aligned symmetrically in a 1-row, 2-column layout.
  • FlowLayout: Positions the task count status label cleanly on the bottom-left corner.

4. Custom Rendering & Thread Safety

  • Cell Renderer Customization: Overrides standard list cell painting to inject alternating white/light-gray backgrounds, a thin separating line, and comfortable text margins.
  • Event Dispatch Thread (EDT): Wrapped within SwingUtilities.invokeLater() to avoid GUI rendering race conditions or deadlocks.

🖥️ How to Run the Application

Prerequisites

  • Make sure you have Java Development Kit (JDK 8 or higher) installed on your machine.
  • Verify installation by running java -version and javac -version in your terminal.

Step 1: Compile the Source Code

Open your terminal/command prompt, navigate to the project directory, and compile the code:

javac ToDoApp.java

Step 2: Run the Executable

Launch the GUI application:

java ToDoApp

📊 Sample Output Representation

When launched, the desktop app opens a graphical window styled like the preview below:

+-------------------------------------------------+
| Task Planner - My To-Do List              _ [] X|
+-------------------------------------------------+
|                                                 |
|  My Tasks                                       |
|  Manage your daily activities and goals         |
|  _____________________________________________  |
|  | [x] Finish the Java internship report      | |
|  | [ ] Read about Java Swing Layouts          | |
|  | [ ] Review the MVC design pattern basics   | |
|  |____________________________________________| |
|                                                 |
|  [ Enter new task description...              ] |
|                                                 |
|  +-----------------------+ +-----------------+  |
|  |       Add Task        | |   Delete Task   |  |
|  +-----------------------+ +-----------------+  |
|                                                 |
|  Total Tasks: 3                                 |
+-------------------------------------------------+

👨‍💻 Author Info

  • Name: Mummana Devi Prasad
  • Role: Java Developer Intern
  • Project Repository: Task 6 - Java GUI To-Do App