Nothing Special   »   [go: up one dir, main page]

Clas 12 Java Project On Library Management System

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 14

LADY FLORENCE CONVENT

SCHOOL

SESSION 2023-2024
STUDENT NAME:___________________________________
CLASS :____________________________________________
ROLL NO._________________________________________
SUBMITTED TO :__________________________________
ACKNOWLEDGEMENT
I would like to express my greatest gratitude to the people who
helped and supported me throughout my project.
I am thankful to my parents and grateful to Mr. Aryan whose
valuable guidance has been the ones that helped me patch this
project and make it full proof success.

Student name : ______________


Class : ______________________
Board Roll no.________________
PROJECT ON
LIBRARY
MANAGEMENT
SYSTEM
INDEX
1. Introduction
2. Software and hardware requirements
3. Procedure
4. Source Code
5. Output screen
6. Further improvement
7. Conclusion
8. Biblography
INTRODUCTION
In this project, we will demonstrate how to develop Library Management System using Java
Swing library. This Library Management System allows you to add books details using a
graphical user interface (GUI) application. This system is build using the Java Swing package
which gives a flexible set of components that can be use to build a Graphical user
interface(GUI).

This application has an easy and simple design with buttons to add books, view books list,
edit the details, delete the book, clear the text fields and exit application. So take a seat,
pour a cup of coffee and start using Library management system.
REQUIREMENTS
Hardware Requirement for Java

Minimum hardware requirement to download Java Programme on your Windows operating

system as follows:

● Windows 7 software

● IBM-compatible 486 system

● Hard Drive and Minimum of 8 MB memory

● A CD-ROM drive

● Mouse, keyboard and sound card, if required

Software requirement for Java

Nowadays, Java is supported by almost every operating system. Whether it is a Windows,

Macintosh and UNIX all supports the Java application development. So you can download

any of the operating system on your personal computer. Here is the minimum requirement.

● Operating System

● Java SDK or JRE 1.6 or higher

● Java Servlet Container (Free Servlet Container available)

● Supported Database and library that supports the database connection with Java.

PROCEDURE
You must have java JDK installed on your system and we are using
Eclipse IDE to build this project, you can use either this or Netbeans IDE.

The first step will be to create a new project. Name it as you wish. In the
src folder create a library package. In that package, we will be creating
some files for different modules.
To connect the system with the database you will need to follow certain
steps.
 Have Java JDK already installed and an IDE like Eclipse
 Install MySQL on the system.
 Download MySQL connector from here.
 In Eclipse, under your project expand external libraries and right-
click, and select Open Library Settings. Select the libraries tab and
click on the + button. Browse your jar file downloaded from the
above step and click on it. This will add a dependency to your
project. The steps will differ if you are using a different IDE.

Source code
1. \\@codewithcurious.com
2. import javax.swing.*;
3. import java.awt.*;
4. import java.awt.event.*;
5. import java.util.*;
6. public class Library_management extends JFrame implements ActionListener {
7. private JLabel label1, label2, label3, label4, label5, label6, label7;
8. private JTextField textField1, textField2, textField3, textField4, textField5, textField6, textField7;
9. private JButton addButton, viewButton, editButton, deleteButton, clearButton,exitButton;
10. private JPanel panel;
11. private ArrayList<String[]> books = new ArrayList<String[]>();
12. public Library_management() {
13. setTitle("Library Management System");
14. setSize(600, 300);
15. setDefaultCloseOperation(EXIT_ON_CLOSE);

16. label1 = new JLabel("Book ID");


17. label2 = new JLabel("Book Title");
18. label3 = new JLabel("Author");
19. label4 = new JLabel("Publisher");
20. label5 = new JLabel("Year of Publication");
21. label6 = new JLabel("ISBN");
22. label7 = new JLabel("Number of Copies");

23. textField1 = new JTextField(10);


24. textField2 = new JTextField(20);
25. textField3 = new JTextField(20);
26. textField4 = new JTextField(20);
27. textField5 = new JTextField(10);
28. textField6 = new JTextField(20);
29. textField7 = new JTextField(10);

30. addButton = new JButton("Add");


31. viewButton = new JButton("View");
32. editButton = new JButton("Edit");
33. deleteButton = new JButton("Delete");
34. clearButton = new JButton("Clear");
35. exitButton=new JButton("Exit");

36. addButton.addActionListener(this);

37. viewButton.addActionListener(this);
38. editButton.addActionListener(this);
39. deleteButton.addActionListener(this);
40. clearButton.addActionListener(this);
41. exitButton.addActionListener(this);
42. panel = new JPanel(new GridLayout(10,2));
43. panel.add(label1);
44. panel.add(textField1);
45. panel.add(label2);
46. panel.add(textField2);
47. panel.add(label3);
48. panel.add(textField3);
49. panel.add(label4);
50. panel.add(textField4);
51. panel.add(label5);
52. panel.add(textField5);
53. panel.add(label6);
54. panel.add(textField6);
55. panel.add(label7);
56. panel.add(textField7);
57. panel.add(addButton);
58. panel.add(viewButton);
59. panel.add(editButton);
60. panel.add(deleteButton);
61. panel.add(clearButton);
62. panel.add(exitButton);

63. add(panel);
64. setVisible(true);
65. }

66. public void actionPerformed(ActionEvent e) {


67. if (e.getSource() == addButton) {
68. String[] book = new String[7];
69. book[0] = textField1.getText();
70. book[1] = textField2.getText();
71. book[2] = textField3.getText();
72. book[3] = textField4.getText();
73. book[4] = textField5.getText();
74. book[5] = textField6.getText();
75. book[6] = textField7.getText();
76. books.add(book);
77. JOptionPane.showMessageDialog(this, "Book added successfully");
78. clearFields();
79. }
80. else if (e.getSource() == viewButton) {
81. String[] columns = {"Book ID", "Book Title", "Author", "Publisher", "Year of Publication", "ISBN",
"Number of Copies"};
82. Object[][] data = new Object[books.size()][7];
83. for (int i = 0; i < books.size(); i++) {
84. data[i][0] = books.get(i)[0];
85. data[i][1] = books.get(i)[1];
86. data[i][2] = books.get(i)[2];
87. data[i][3] = books.get(i)[3];
88. data[i][4] = books.get(i)[4];
89. data[i][5] = books.get(i)[5];
90. data[i][6] = books.get(i)[6];
91. }
92. JTable table = new JTable(data, columns);
93. JScrollPane scrollPane = new JScrollPane(table);
94. JFrame frame = new JFrame("View Books");
95. frame.add(scrollPane);
96. frame.setSize(800, 400);
97. frame.setVisible(true);
98. }
99. else if (e.getSource() == editButton) {

String bookID = JOptionPane.showInputDialog(this, "Enter book ID to edit:");


for (int i = 0; i < books.size(); i++) {
if (books.get(i)[0].equals(bookID)) {
String[] book = new String[7];
book[0] = bookID;
book[1] = textField2.getText();
book[2] = textField3.getText();
book[3] = textField4.getText();
book[4] = textField5.getText();
book[5] = textField6.getText();
book[6] = textField7.getText();
books.set(i, book);
JOptionPane.showMessageDialog(this, "Book edited successfully");
clearFields();
return;
}
}
JOptionPane.showMessageDialog(this, "Book not found");
}
else if (e.getSource() == deleteButton) {
String bookID = JOptionPane.showInputDialog(this, "Enter book ID to delete:");
for (int i = 0; i < books.size(); i++) {
if (books.get(i)[0].equals(bookID)) {
books.remove(i);
JOptionPane.showMessageDialog(this, "Book deleted successfully");
clearFields();
return;
}
}
JOptionPane.showMessageDialog(this, "Book not found");
}
else if (e.getSource() == clearButton) {
clearFields();
}
else if (e.getSource() == exitButton) {
System.exit(0);
}
}
private void clearFields() {
textField1.setText("");
textField2.setText("");
textField3.setText("");
textField4.setText("");
textField5.setText("");
textField6.setText("");
textField7.setText("");
}

public static void main(String[] args) {


new Library_management();
}
}
OUTPUT SCREEN

CONCLUSION
In this project, we developed a GUI-based project, a Library
Management System Project in Java and MySQL or in other words book library
management system code in java. The users are able to perform the
operations such as Login, View Categories, Book details, Author details, Book
issue, and Book return.

BIBLOGRAPHY

You might also like