This project is a Java-based Library Management System with a simple Graphical User Interface (GUI) created using Swing
. The program enables users to perform basic library management tasks such as adding, viewing, editing, and deleting book records. The application also saves and loads book data from a file to maintain persistence.
- Add Book: Allows users to add new books by providing details such as Book ID, Title, Author, Publisher, Year of Publication, ISBN, and Number of Copies.
- View Books: Displays all books in a table format.
- Edit Book: Enables editing of an existing book's information by entering the Book ID and updating other details.
- Delete Book: Removes a book entry based on its Book ID.
- Clear Fields: Clears all input fields.
- Exit: Exits the application and saves the current state of book records to a file.
- Main Class (
One
): This class contains the GUI components and action listeners for the Library Management System. - Data Persistence: Book data is stored in a text file (
library_data.txt
) to retain information across sessions. When the application starts, it loads data from this file, and upon exit or data changes, it saves the data back to the file.
- Java 8 or higher
javax.swing
andjava.awt
libraries (included in standard Java distributions)
- Compile the code using
javac One.java
. - Run the application using
java One
. - Interacting with the GUI:
- Enter book details and use the
Add
button to save new entries. - Click
View
to open a new window displaying all books. - To edit or delete a book, enter its Book ID, update fields as needed, and click the corresponding button.
- Enter book details and use the
- library_data.txt: This file stores book records in CSV format. Each line represents a book entry with fields separated by commas.
- Initialize: Loads existing book data from
library_data.txt
when the application starts. - Add/Edit/Delete/View Operations: Modifies the in-memory data and updates the file upon changes.
- Exit: Ensures all data is saved to
library_data.txt
before the program closes.
JTextField
: Used for user input fields (e.g., Book ID, Title).JButton
: Triggers actions such as adding or viewing books.JTable
: Displays a list of all books in the View Books feature.ArrayList<String[]>
: Stores book data temporarily within the application.
-
Adding a Book:
- Enter details in the respective fields.
- Click
Add
to save the entry. The program will confirm the addition.
-
Editing a Book:
- Enter the
Book ID
of the book to edit. - Update any fields and click
Edit
. The program will confirm if the update is successful.
- Enter the
-
Viewing All Books:
- Click
View
to see a list of all books in a new table window.
- Click
-
Deleting a Book:
- Enter the
Book ID
of the book to delete and clickDelete
. A confirmation message will appear.
- Enter the
This project is licensed under the MIT License.