0% found this document useful (0 votes)
2 views10 pages

AJP Introduction 2

Uploaded by

saqibzuber813
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views10 pages

AJP Introduction 2

Uploaded by

saqibzuber813
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Advanced Java Micro Project Event Reminder Application

Introduction to
“Event Reminder Application Micro Project”
The Event Reminder Application is an intuitive and interactive desktop tool built using Java
Swing, developed as an advanced Java micro project. This application enables users to create,
edit, and delete events while setting reminders and priorities to help users stay organized.
With a focus on usability, it provides a straightforward interface to manage tasks and track
important dates, incorporating essential features for maintaining and prioritizing events.
Key Components and Functionalities
1. Event Management: Users can add new events, providing details such as title,
description, date, time, and priority level (High, Medium, Low). Each event is stored
as an Event object with all necessary attributes, such as title, description, dateTime,
and priority.
2. Graphical User Interface (GUI): Built using Java Swing, the application offers a
user-friendly and visually organized interface. The JList component displays events,
with buttons for adding, editing, and deleting items located at the bottom for quick
access.
3. Interactive Event Form: A separate form appears to enter or modify event details. It
includes text areas for the title and description, fields for date and time, and a
dropdown menu for priority. The form’s layout ensures that users can easily read and
input event data.
4. Priority-Based Sorting and Display: Events can be prioritized, enabling users to set
the importance of each task. The priority levels assist in planning by distinguishing
tasks based on urgency.

Code Structure
• Event Class: Handles event data, including title, description, date and time, and
priority. The class includes getters, setters, and a toString method to display event
summaries in the list.
• EventReminderApp Class: Controls the application's main functionalities, including
initializing the GUI, managing the event list, and handling user actions (add, edit,
delete). The openEventForm method enables editing within a dedicated dialog box.
• Java Swing Components: Utilizes JFrame, JList, JTextArea, JTextField, and
JComboBox to create a dynamic interface, allowing users to interact with the
application seamlessly.
Technical Overview
This project exemplifies advanced Java concepts, including object-oriented programming,
GUI design, and data handling. It showcases an application of Java Swing for real-world
scenarios, providing a practical tool for personal organization and event tracking.

Page 1 of 10
Advanced Java Micro Project Event Reminder Application

Project Code:
Event.java Class Code:
package vansh;

import java.time.LocalDateTime;

public class Event {


private String title;
private String description;
private LocalDateTime dateTime;
private String priority;

public Event(String title, String description, LocalDateTime dateTime, String priority) {


this.title = title;
this.description = description;
this.dateTime = dateTime;
this.priority = priority;
}

// Getters and Setters


public String getTitle() { return title; }
public void setTitle(String title) { this.title = title; }

public String getDescription() { return description; }


public void setDescription(String description) { this.description = description; }

public LocalDateTime getDateTime() { return dateTime; }


public void setDateTime(LocalDateTime dateTime) { this.dateTime = dateTime; }

public String getPriority() { return priority; }


public void setPriority(String priority) { this.priority = priority; }

@Override
public String toString() {
return title + " - " + dateTime.toString() + " (" + priority + ")";
}
}

Page 2 of 10
Advanced Java Micro Project Event Reminder Application

EventReminderApp.java Class Code:


package vansh;

import javax.swing.*;
import java.awt.*;
import java.time.LocalDateTime;
import java.util.ArrayList;

public class EventReminderApp {


private JFrame frame;
private DefaultListModel<Event> eventListModel;
private JList<Event> eventList;
private ArrayList<Event> events;
public EventReminderApp() {
events = new ArrayList<>();
initialize();
}
private void initialize() {
frame = new JFrame("Event Reminder Tool");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(600, 400);
frame.setLayout(new BorderLayout());

// Event List
eventListModel = new DefaultListModel<>();
eventList = new JList<>(eventListModel);
eventList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
JScrollPane scrollPane = new JScrollPane(eventList);

// Buttons Panel
JPanel buttonPanel = new JPanel();
JButton addButton = new JButton("Add Event");
JButton editButton = new JButton("Edit Event");
JButton deleteButton = new JButton("Delete Event");

addButton.addActionListener(e -> openEventForm(null));


editButton.addActionListener(e -> openEventForm(eventList.getSelectedValue()));
deleteButton.addActionListener(e -> deleteEvent());

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

// Add Components to Frame


frame.add(scrollPane, BorderLayout.CENTER);

Page 3 of 10
Advanced Java Micro Project Event Reminder Application

frame.add(buttonPanel, BorderLayout.SOUTH);

frame.setVisible(true);
}

private void openEventForm(Event eventToEdit) {


JDialog dialog = new JDialog(frame, "Event Form", true);
dialog.setSize(400, 400);
dialog.setLayout(new BorderLayout());

JPanel inputPanel = new JPanel();


inputPanel.setLayout(new GridLayout(6, 2, 5, 5)); // Adding vertical and horizontal gap

JTextArea titleArea = new JTextArea(eventToEdit != null ? eventToEdit.getTitle() : "",


2, 20);
JTextArea descriptionArea = new JTextArea(eventToEdit != null ?
eventToEdit.getDescription() : "", 10, 20); // Increased rows for description

// Setting black minimalistic borders for JTextAreas


titleArea.setBorder(BorderFactory.createLineBorder(Color.BLACK));
descriptionArea.setBorder(BorderFactory.createLineBorder(Color.BLACK));

JTextField dateField = new JTextField(eventToEdit != null ?


eventToEdit.getDateTime().toLocalDate().toString() : "");
JTextField timeField = new JTextField(eventToEdit != null ?
eventToEdit.getDateTime().toLocalTime().toString() : "");

// Setting black minimalistic borders for JTextFields


dateField.setBorder(BorderFactory.createLineBorder(Color.BLACK));
timeField.setBorder(BorderFactory.createLineBorder(Color.BLACK));

JComboBox<String> priorityBox = new JComboBox<>(new String[]{"High",


"Medium", "Low"});
if (eventToEdit != null) {
priorityBox.setSelectedItem(eventToEdit.getPriority());
}

JButton saveButton = new JButton("Save");

// Increase height of Save button


saveButton.setPreferredSize(new Dimension(saveButton.getPreferredSize().width, 37));
// Adjust the height as needed

saveButton.addActionListener(e -> {
String title = titleArea.getText();
String description = descriptionArea.getText();

Page 4 of 10
Advanced Java Micro Project Event Reminder Application

LocalDateTime dateTime = LocalDateTime.parse(dateField.getText() + "T" +


timeField.getText());
String priority = (String) priorityBox.getSelectedItem();

if (eventToEdit != null) {
eventToEdit.setTitle(title);
eventToEdit.setDescription(description);
eventToEdit.setDateTime(dateTime);
eventToEdit.setPriority(priority);
eventList.repaint();
} else {
Event newEvent = new Event(title, description, dateTime, priority);
events.add(newEvent);
eventListModel.addElement(newEvent);
}
dialog.dispose();
});

inputPanel.add(new JLabel("Title:"));
inputPanel.add(titleArea);
inputPanel.add(new JLabel("Description:"));
inputPanel.add(descriptionArea);
inputPanel.add(new JLabel("Date (YYYY-MM-DD):"));
inputPanel.add(dateField);
inputPanel.add(new JLabel("Time (HH:MM):"));
inputPanel.add(timeField);
inputPanel.add(new JLabel("Priority:"));
inputPanel.add(priorityBox);

dialog.add(inputPanel, BorderLayout.CENTER);
dialog.add(saveButton, BorderLayout.SOUTH);

dialog.setVisible(true);
}

private void deleteEvent() {


Event selectedEvent = eventList.getSelectedValue();
if (selectedEvent != null) {
events.remove(selectedEvent);
eventListModel.removeElement(selectedEvent);
}
}
public static void main(String[] args) {
SwingUtilities.invokeLater(EventReminderApp::new);
}
}

Page 5 of 10
Advanced Java Micro Project Event Reminder Application

Output:

Event Reminder

Create Event

Page 6 of 10
Advanced Java Micro Project Event Reminder Application

Creating Event

Event Created

Page 7 of 10
Advanced Java Micro Project Event Reminder Application

Edit Event

Event Edited

Page 8 of 10
Advanced Java Micro Project Event Reminder Application

Creating Multiple Events

Deleted Event

Page 9 of 10
Advanced Java Micro Project Event Reminder Application

Conclusion:
This micro project demonstrates the development of a basic Event Reminder
Application using advanced Java concepts and Java Swing for GUI. Through
this project, we have effectively implemented object-oriented programming,
event handling, and graphical interface design. The application allows users to
create, edit, and delete events with specific details, including title, description,
date, time, and priority.
Developing this project has provided practical insights into building interactive
desktop applications, especially focusing on user experience and data
management. We chose this application because event management is a
common task, and a simple tool like this can be useful for organizing personal
schedules. This project has enhanced our understanding of structuring Java
applications and utilizing Java Swing components to design functional and user-
friendly interfaces.

Reference:
• Corsera
• TutorialsPoint
• YouTube

Page 10 of 10

You might also like