Skip to content

Coder0202/Calendar-Application

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 

Repository files navigation

Calendar-Application

๐Ÿ”น OVERVIEW program is made of two main parts:

CalendarApplication class โ€“ The main GUI window using Java Swing.

Event class โ€“ A model class that represents an individual calendar event.

๐Ÿ”น CLASS: CalendarApplication (extends JFrame) This is the main class and the graphical user interface (GUI) for the application.

๐Ÿ”ธ Fields: List events โ€“ Stores all the events.

JList eventList โ€“ A Swing component to display the list of events.

DefaultListModel listModel โ€“ Used by JList to hold the actual event items.

JButton addButton, editButton, deleteButton โ€“ Buttons for user interaction.

๐Ÿ”ธ main() Method: java Copy Edit SwingUtilities.invokeLater(() -> new CalendarApplication().setVisible(true)); Starts the GUI on the Event Dispatch Thread (standard practice in Swing).

๐Ÿ”ธ Constructor: java Copy Edit public CalendarApplication() Sets window title, close operation, size, and calls initComponents() to set up the UI.

๐Ÿ”ธ Method: initComponents() Initializes all GUI components:

Creates the JList, buttons, and a panel for controls.

Adds the event list to the center of the frame and the buttons to the bottom.

Adds ActionListeners to handle button clicks for adding, editing, and deleting events.

๐Ÿ”ธ Method: createNewEvent() Prompts the user to enter:

Event name

Date (in yyyy-MM-dd format)

If input is valid:

Parses the date string into a Date object.

Creates a new Event and returns it.

If invalid input, shows an error dialog.

๐Ÿ”ธ Method: editEvent(Event event) Prompts the user to update the name and date of the selected event.

If valid input is given, updates the event's name and date.

If the date format is wrong, shows an error dialog.

๐Ÿ”ธ Method: updateEventList() Clears and refreshes the JList (eventList) by re-adding all events from the events list.

๐Ÿ”น CLASS: Event A simple class to represent an event with a name and date.

๐Ÿ”ธ Fields: String name โ€“ Event name.

Date date โ€“ Event date.

๐Ÿ”ธ Constructor: java Copy Edit public Event(String name, Date date) Initializes the name and date for the event.

๐Ÿ”ธ Getters and Setters: getName(), setName(String)

getDate(), setDate(Date)

๐Ÿ”ธ Method: getDateStr() Converts the Date to a String in "yyyy-MM-dd" format for display.

๐Ÿ”ธ Method: toString() java Copy Edit @Override public String toString() { return "Event: " + name + " Date: " + getDateStr(); } Used to display each event in the JList as a formatted string.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages