Javamicro
Javamicro
This is to certify that Atharva Kamble, Muzzamil Chikkali, Sairaj Patwardhan, Abhishek Kadam
students of Fourth Semester of Diploma in Computer Engineering of Rajendra Mane Polytechnic,
Ambav (Code:1507) have submitted the proposal for micro-project entitled ‘Java-Based To-Do List
Application with User Authentication and File-Based Storage ’ in the Subject Java Programming (Sub.
Code: 314321) for the Academic Year 2024-25. The micro-project proposal for a forementioned title has
been approved for its completion as per the MSBTE instructions.
Date:
Place: Rajendra Mane Polytechnic, Ambav, Devrukh
CERTIFICATE
This is to certify that students Atharva Kamble, Muzzamil Chikkali, Sairaj Patwardhan, Abhishek
Kadam of Fourth Semester of Diploma in Computer Engineering of Rajendra Mane Polytechnic,
Ambav (Code: 1507) have submitted the microproject and defended the viva-voice of the term work
micro-project entitled “Java-Based To-Do List Application with User Authentication and File-Based
Storage” for the Academic Year 2024-24 as prescribed in the curriculum.
Action plan
Sr. No. Details of the activity Planned start Planned Name of
Date finish Date Responsible
Team Member
1 Finalizing the topic All the Member
Resources required
Sr. No. Name of Resources / Specifications Quantity Remarks
material
1. Computer 2 GB RAM and Use computer
available in
Pentium is i3 With
language lab
MS Office & Graphics
& Internet
2. printer B & W printer & Use printer
Colour available at
computer lab
3. Printing Papers A4 size -
Java GUI To-Do List Application with Login System and File Storage
1.1 Type of Project
This is a desktop-based GUI application.
1.2 Programming Language
Java (JDK 11 or above).
1.3 User Interface
Implemented using Java Swing for a professional and responsive GUI.
1.4 Data Storage
File-based system using .txt files for both user authentication and task management.
2. Introduction
This project is a beginner-friendly yet advanced Java GUI application developed as a diploma microproject.
It allows users to register, log in, and manage personal to-do tasks. The application features a graphical user
interface using Java Swing and stores user data and tasks in simple .txt files. This design simulates real-
world applications without requiring a database.
2.1 Purpose
To provide a reliable personal task manager with secure login.
2.2 Audience
Ideal for students, professionals, and anyone needing a basic task management system.
2.3 Scope
This application can be enhanced for larger-scale deployment using databases or cloud services.
3. Objective
To build a Java application that manages daily tasks.
To implement a secure login system.
To demonstrate file handling and user-based data management.
To enhance GUI programming skills using Java Swing.
To simulate real-world application development practices.
4. Software Requirements
Java Development Kit (JDK 11 or above)
Visual Studio Code / IntelliJ / Eclipse
Operating System: Windows/Linux/MacOS
No external database required
Java Swing library (bundled in JDK)
4.1 Optional Tools
Git for version control
JAR compiler for packaging
5. Key Features
5.1 User Registration and Login
o New users can register using a unique ID and password.
o Directories used: /users for login info, /tasks for to-do items.
6. Project Structure :
7. Technologies Used
Java: Main programming language.
Java Swing: GUI development.
File I/O: Reading and writing user data.
AWT & Event Handling: Managing user actions like button clicks.
7.1 Why Java?
Platform-independent
Strong community support
Integrated development environments (IDEs) available for ease of development
Code :
● import javax.swing.*;
● import java.awt.*;
● import java.awt.event.*;
● import java.io.*;
● import java.util.*;
●
● public class ToDoApp {
●
● static final File USERS_DIR = new File("users");
● static final File TASKS_DIR = new File("tasks");
●
● static DefaultListModel<String> taskModel = new DefaultListModel<>();
● static JList<String> taskList = new JList<>(taskModel);
● static String currentUserId = null;
●
● public static void main(String[] args) {
● if (!USERS_DIR.exists()) USERS_DIR.mkdir();
● if (!TASKS_DIR.exists()) TASKS_DIR.mkdir();
● SwingUtilities.invokeLater(ToDoApp::showLoginScreen);
● }
●
● static void showLoginScreen() {
● JFrame loginFrame = new JFrame("Login");
● loginFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
● loginFrame.setSize(300, 200);
● loginFrame.setLayout(new GridLayout(4, 2));
●
● JTextField userIdField = new JTextField();
● JPasswordField passwordField = new JPasswordField();
● JButton loginButton = new JButton("Login");
● JButton registerButton = new JButton("Register");
●
● loginFrame.add(new JLabel("User ID:"));
● loginFrame.add(userIdField);
● loginFrame.add(new JLabel("Password:"));
● loginFrame.add(passwordField);
● loginFrame.add(loginButton);
● loginFrame.add(registerButton);
●
● loginButton.addActionListener(e -> {
● String userId = userIdField.getText().trim();
● String pass = new String(passwordField.getPassword()).trim();
● if (checkLogin(userId, pass)) {
● currentUserId = userId;
● loginFrame.dispose();
● showToDoApp();
● } else {
● JOptionPane.showMessageDialog(loginFrame, "Invalid
credentials. Please register.");
● }
● });
●
● registerButton.addActionListener(e -> {
● String userId = userIdField.getText().trim();
● String pass = new String(passwordField.getPassword()).trim();
● if (userId.isEmpty() || pass.isEmpty()) {
● JOptionPane.showMessageDialog(loginFrame, "Enter valid ID and
Password");
● return;
● }
● File userFile = new File(USERS_DIR, userId + ".txt");
● if (userFile.exists()) {
● JOptionPane.showMessageDialog(loginFrame, "User already
exists.");
● } else {
● try (PrintWriter writer = new PrintWriter(userFile)) {
● writer.println(pass);
● } catch (IOException ex) {
● ex.printStackTrace();
● }
● JOptionPane.showMessageDialog(loginFrame, "User registered!
You can now login.");
● }
● });
●
● loginFrame.setVisible(true);
● }
●
● static boolean checkLogin(String userId, String password) {
● File userFile = new File(USERS_DIR, userId + ".txt");
● if (!userFile.exists()) return false;
● try (BufferedReader br = new BufferedReader(new
FileReader(userFile))) {
● String storedPassword = br.readLine();
● return storedPassword.equals(password);
● } catch (IOException e) {
● e.printStackTrace();
● }
● return false;
● }
●
● static void showToDoApp() {
● JFrame frame = new JFrame("To-Do List - User: " + currentUserId);
● frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
● frame.setSize(500, 400);
● frame.setLayout(new BorderLayout());
●
● taskModel.clear();
● loadTasks(currentUserId);
●
● JPanel buttonPanel = new JPanel();
● JButton addButton = new JButton("Add Task");
● JButton editButton = new JButton("Edit Task");
● JButton deleteButton = new JButton("Delete Task");
●
● buttonPanel.add(addButton);
● buttonPanel.add(editButton);
● buttonPanel.add(deleteButton);
●
● frame.add(new JScrollPane(taskList), BorderLayout.CENTER);
● frame.add(buttonPanel, BorderLayout.SOUTH);
●
● addButton.addActionListener(e -> {
● JTextField taskName = new JTextField();
● JTextField taskTime = new JTextField();
● Object[] message = {
● "Task Name:", taskName,
● "Time:", taskTime
● };
● int option = JOptionPane.showConfirmDialog(frame, message, "Add
Task", JOptionPane.OK_CANCEL_OPTION);
● if (option == JOptionPane.OK_OPTION) {
● String name = taskName.getText().trim();
● String time = taskTime.getText().trim();
● if (!name.isEmpty() && !time.isEmpty()) {
● String taskEntry = name + " | Time: " + time;
● taskModel.addElement(taskEntry);
● saveTasks(currentUserId, taskModel);
● }
● }
● });
●
● editButton.addActionListener(e -> {
● int index = taskList.getSelectedIndex();
● if (index >= 0) {
● String current = taskModel.getElementAt(index);
● String[] parts = current.split("\\| Time: ");
● JTextField taskName = new JTextField(parts[0].trim());
● JTextField taskTime = new JTextField(parts.length > 1 ?
parts[1].trim() : "");
●
● Object[] message = {
● "Edit Task Name:", taskName,
● "Edit Time:", taskTime
● };
● int option = JOptionPane.showConfirmDialog(frame, message,
"Edit Task", JOptionPane.OK_CANCEL_OPTION);
● if (option == JOptionPane.OK_OPTION) {
● String name = taskName.getText().trim();
● String time = taskTime.getText().trim();
● if (!name.isEmpty() && !time.isEmpty()) {
● String taskEntry = name + " | Time: " + time;
● taskModel.set(index, taskEntry);
● saveTasks(currentUserId, taskModel);
● }
● }
● } else {
● JOptionPane.showMessageDialog(frame, "Select a task to
edit.");
● }
● });
●
● deleteButton.addActionListener(e -> {
● int index = taskList.getSelectedIndex();
● if (index >= 0) {
● taskModel.remove(index);
● saveTasks(currentUserId, taskModel);
● } else {
● JOptionPane.showMessageDialog(frame, "Select a task to
delete.");
● }
● });
●
● frame.setVisible(true);
● }
●
● static void loadTasks(String userId) {
● File taskFile = new File(TASKS_DIR, userId + "_tasks.txt");
● if (taskFile.exists()) {
● try (BufferedReader br = new BufferedReader(new
FileReader(taskFile))) {
● String line;
● while ((line = br.readLine()) != null) {
● taskModel.addElement(line);
● }
● } catch (IOException e) {
● e.printStackTrace();
● }
● }
● }
●
● static void saveTasks(String userId, DefaultListModel<String> model) {
● File taskFile = new File(TASKS_DIR, userId + "_tasks.txt");
● try (PrintWriter writer = new PrintWriter(new FileWriter(taskFile)))
{
● for (int i = 0; i < model.size(); i++) {
● writer.println(model.getElementAt(i));
● }
● } catch (IOException e) {
● e.printStackTrace();
● }
● }
● }
●
8. Application Flow
1. Launch the application.
2. User either registers or logs in.
3. On login success, the user is redirected to the To-Do List GUI.
4. Tasks can be added, edited, or deleted using buttons.
5. All actions automatically update the task file.
8.1 Error Handling
Invalid credentials return clear error messages.
Attempting to login before registration is prevented.
File handling errors are managed with exception handling.
9. Advantages
No need for internet or external databases.
Great for understanding basic authentication logic.
File-based structure simulates real-time data handling.
GUI is clean, intuitive, and visually appealing.
Platform-independent and can run on any machine with Java.
9.1 Educational Value
This project strengthens knowledge of:
Object-oriented programming
GUI event handling
File input/output
User interaction design
10. Conclusion
This Java microproject provides a complete package to understand file I/O, GUI development, and basic
authentication in Java. It’s ideal for diploma students aiming to impress with a clean, working, and real-life
inspired application. The separation of user data and task lists enhances privacy and provides a scalable base
for further development.
10.1 Key Learnings
Importance of clean code structure
GUI layout design and alignment
Reading and writing from files securely
Handling real-world logic with validations