Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SY_53_College Level Application #24

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
10 changes: 10 additions & 0 deletions 53-TechTitans/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-18">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
28 changes: 28 additions & 0 deletions 53-TechTitans/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>TaskManager</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<filteredResources>
<filter>
<id>1714473260680</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
2 changes: 2 additions & 0 deletions 53-TechTitans/.settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
14 changes: 14 additions & 0 deletions 53-TechTitans/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=18
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=18
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=18
33 changes: 33 additions & 0 deletions 53-TechTitans/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Task Manager GUI
The Task Manager GUI is a Java application designed to help users manage their tasks effectively. It provides a graphical user interface (GUI) for adding, viewing, and deleting tasks, along with displaying task details such as title, description, and deadline.

Features
Add Task: Users can add new tasks by providing a title, description, and deadline in the specified format (dd/MM/yyyy HH:mm).
View Tasks: Users can view all added tasks sorted by their deadlines.The task which is to be done first is displayed first based on the deadline. Tasks are displayed in a text area within the GUI.
Delete Task: Users can select and delete tasks from the list. Tasks are deleted based on their titles.


Tools andTechniques used
ArrayList: Used to store the tasks added by the user. The ArrayList allows for dynamic resizing and efficient storage and retrieval of task objects.
Date: Utilized to represent task deadlines. Dates are parsed and formatted using the SimpleDateFormat class, ensuring consistency and compatibility with user input and display.
JTextArea: Used to display tasks within the GUI. The JTextArea component provides a scrollable text area for presenting task details to the user.
JScrollPane: Incorporated to enable scrolling functionality within the JTextArea when the number of tasks exceeds the visible area, ensuring a seamless user experience.
Custom Comparator: Implemented a custom comparator (TaskComparator) to sort tasks based on their deadlines. This comparator is used in conjunction with Collections.sort() to maintain tasks in ascending order of deadlines.


Requirements
Java Development Kit (JDK)
Java Swing library for GUI components
Video Link
https://drive.google.com/file/d/19CG9PDrTrxDTZPwUtqw-EiJAGBzpJ2y3/view?usp=sharing






15 Day Report 1:
https://docs.google.com/document/d/12FsSRyhOI-NnVypT2zaPgVI-l46HSBTjMBG_fGUeczg/edit?usp=sharing

15 Day Report 2:
https://docs.google.com/document/d/16XrLwLSu-Wkn_sPkGkDTiV9RffEM6ZMwkeWE_xL0a1Q/edit?usp=sharing
Binary file added 53-TechTitans/bin/Task.class
Binary file not shown.
Binary file added 53-TechTitans/bin/TaskComparator.class
Binary file not shown.
Binary file added 53-TechTitans/bin/TaskManagerGUI$1.class
Binary file not shown.
Binary file added 53-TechTitans/bin/TaskManagerGUI$2.class
Binary file not shown.
Binary file added 53-TechTitans/bin/TaskManagerGUI$3.class
Binary file not shown.
Binary file added 53-TechTitans/bin/TaskManagerGUI$4.class
Binary file not shown.
Binary file added 53-TechTitans/bin/TaskManagerGUI.class
Binary file not shown.
164 changes: 164 additions & 0 deletions 53-TechTitans/src/TaskManagerGUI.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;

public class TaskManagerGUI extends JFrame {
private ArrayList<Task> tasks;
private JTextArea taskTextArea;

public TaskManagerGUI() {
tasks = new ArrayList<>();

setTitle("Task Manager");
setSize(400, 300);
setDefaultCloseOperation(EXIT_ON_CLOSE);

JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BorderLayout());

taskTextArea = new JTextArea();
JScrollPane scrollPane = new JScrollPane(taskTextArea);
mainPanel.add(scrollPane, BorderLayout.CENTER);

JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new FlowLayout());

JButton addButton = new JButton("Add Task");
addButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
addTask();
}
});

JButton viewButton = new JButton("View Tasks");
viewButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
viewTasks();
}
});

JButton deleteButton = new JButton("Delete Task");
deleteButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
deleteTask();
}
});

buttonPanel.add(addButton);
buttonPanel.add(viewButton);
buttonPanel.add(deleteButton);

mainPanel.add(buttonPanel, BorderLayout.SOUTH);

add(mainPanel);
setVisible(true);
}

private void addTask() {
String title = JOptionPane.showInputDialog("Enter task title:");
String description = JOptionPane.showInputDialog("Enter task description:");
String deadlineStr = JOptionPane.showInputDialog("Enter task deadline (format: dd/MM/yyyy HH:mm):");

SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm");
Date deadline;
try {
deadline = dateFormat.parse(deadlineStr);
} catch (ParseException e) {
JOptionPane.showMessageDialog(this, "Invalid date format! Please enter in the format: dd/MM/yyyy HH:mm");
return;
}

Task newTask = new Task(title, description, deadline);
tasks.add(newTask);
Collections.sort(tasks, new TaskComparator()); // Sort tasks based on priority
taskTextArea.append("Task added successfully!\n");
}

private void viewTasks() {
if (tasks.isEmpty()) {
taskTextArea.setText("No tasks to display.");
} else {
taskTextArea.setText("");
for (Task task : tasks) {
taskTextArea.append(task.toString() + "\n");
}
}
}

private void deleteTask() {
if (tasks.isEmpty()) {
JOptionPane.showMessageDialog(this, "No tasks to delete.");
} else {
String[] taskTitles = new String[tasks.size()];
for (int i = 0; i < tasks.size(); i++) {
taskTitles[i] = tasks.get(i).getTitle();
}
String selectedTitle = (String) JOptionPane.showInputDialog(this, "Select task to delete:",
"Delete Task", JOptionPane.PLAIN_MESSAGE, null, taskTitles, taskTitles[0]);
if (selectedTitle != null) {
for (Task task : tasks) {
if (task.getTitle().equals(selectedTitle)) {
tasks.remove(task);
taskTextArea.append("Task '" + selectedTitle + "' deleted successfully!\n");
return;
}
}
}
}
}

public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
new TaskManagerGUI();
}
});
}
}

class Task {
private String title;
private String description;
private Date deadline;

public Task(String title, String description, Date deadline) {
this.title = title;
this.description = description;
this.deadline = deadline;
}

public String getTitle() {
return title;
}

public String getDescription() {
return description;
}

public Date getDeadline() {
return deadline;
}

@Override
public String toString() {
return "Title: " + title + ", Description: " + description + ", Deadline: " + deadline;
}
}

class TaskComparator implements Comparator<Task> {
@Override
public int compare(Task t1, Task t2) {
return t1.getDeadline().compareTo(t2.getDeadline());
}
}