CODE:-
Library.java
package librarymanagementssystem;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.GroupLayout.Alignment;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.border.EmptyBorder;
public class Library extends JFrame {
static Library frame;
private JPanel contentPane;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
frame= new Library();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public Library() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
JLabel lblLibraryManagement = new JLabel("Library Management ");
lblLibraryManagement.setFont(new Font("Tahoma", Font.PLAIN, 18));
lblLibraryManagement.setForeground(Color.GRAY);
JButton btnAdminLogin = new JButton("Admin Login");
btnAdminLogin.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
AdminLogin.main(new String[]{});
frame.dispose();
}
});
btnAdminLogin.setFont(new Font("Tahoma", Font.PLAIN, 15));
JButton btnLibrarianLogin = new JButton("Librarian Login");
btnLibrarianLogin.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
LibrarianLogin.main(new String[]{});
}
});
btnLibrarianLogin.setFont(new Font("Tahoma", Font.PLAIN, 15));
GroupLayout gl_contentPane = new GroupLayout(contentPane);
gl_contentPane.setHorizontalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(64)
.addComponent(lblLibraryManagement))
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(140)
.addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING, false)
.addComponent(btnLibrarianLogin, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnAdminLogin, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 135, Short.MAX_VALUE))))
.addContainerGap(95, Short.MAX_VALUE))
);
gl_contentPane.setVerticalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addContainerGap()
.addComponent(lblLibraryManagement)
.addGap(32)
.addComponent(btnAdminLogin, GroupLayout.PREFERRED_SIZE, 52, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(btnLibrarianLogin, GroupLayout.PREFERRED_SIZE, 53, GroupLayout.PREFERRED_SIZE)
.addContainerGap(70, Short.MAX_VALUE))
);
contentPane.setLayout(gl_contentPane);
}
}
output:
AdminLogin.java
package librarymanagementssystem;
import librarymanagementssystem.AdminSuccess;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import java.awt.Font;
import java.awt.Color;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JPasswordField;
public class AdminLogin extends JFrame {
static AdminLogin frame;
private JPanel contentPane;
private JTextField textField;
private JPasswordField passwordField;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
frame = new AdminLogin();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public AdminLogin() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
JLabel lblAdminLoginForm = new JLabel("Admin Login Form");
lblAdminLoginForm.setForeground(Color.GRAY);
lblAdminLoginForm.setFont(new Font("Tahoma", Font.PLAIN, 18));
JLabel lblEnterName = new JLabel("Enter Name:");
JLabel lblEnterPassword = new JLabel("Enter Password:");
textField = new JTextField();
textField.setColumns(10);
JButton btnLogin = new JButton("Login");
btnLogin.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String name=textField.getText();
String password=String.valueOf(passwordField.getPassword());
if(name.equals("admin")&&password.equals("admin123")){
AdminSuccess.main(new String[]{});
frame.dispose();
}else{
JOptionPane.showMessageDialog(AdminLogin.this, "Sorry, Username or Password Error","Login Error!", JOptionPane.ERROR_MESSAGE);
textField.setText("");
passwordField.setText("");
}
}
});
passwordField = new JPasswordField();
GroupLayout gl_contentPane = new GroupLayout(contentPane);
gl_contentPane.setHorizontalGroup(
gl_contentPane.createParallelGroup(Alignment.TRAILING)
.addGroup(gl_contentPane.createSequentialGroup()
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(124)
.addComponent(lblAdminLoginForm))
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(19)
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addComponent(lblEnterName)
.addComponent(lblEnterPassword))
.addGap(47)
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING, false)
.addComponent(passwordField)
.addComponent(textField, GroupLayout.DEFAULT_SIZE, 172, Short.MAX_VALUE))))
.addContainerGap(107, Short.MAX_VALUE))
.addGroup(gl_contentPane.createSequentialGroup()
.addContainerGap(187, Short.MAX_VALUE)
.addComponent(btnLogin, GroupLayout.PREFERRED_SIZE, 86, GroupLayout.PREFERRED_SIZE)
.addGap(151))
);
gl_contentPane.setVerticalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addComponent(lblAdminLoginForm)
.addGap(26)
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(lblEnterName)
.addComponent(textField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(28)
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(lblEnterPassword)
.addComponent(passwordField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(18)
.addComponent(btnLogin, GroupLayout.PREFERRED_SIZE, 37, GroupLayout.PREFERRED_SIZE)
.addContainerGap(80, Short.MAX_VALUE))
);
contentPane.setLayout(gl_contentPane);
}
}
output:
AdminSuccess.java
package librarymanagementssystem;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JLabel;
import java.awt.Color;
import java.awt.Font;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.LayoutStyle.ComponentPlacement;
import java.sql.*;
public class AdminSuccess extends JFrame {
static AdminSuccess frame;
private JPanel contentPane;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
frame = new AdminSuccess();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public AdminSuccess() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 371);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
JLabel lblAdminSection = new JLabel("Admin Section");
lblAdminSection.setFont(new Font("Tahoma", Font.PLAIN, 22));
lblAdminSection.setForeground(Color.GRAY);
JButton btnNewButton = new JButton("Add Librarian");
btnNewButton.setFont(new Font("Tahoma", Font.PLAIN, 15));
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
LibrarianForm.main(new String[]{});
frame.dispose();
}
});
JButton btnViewLibrarian = new JButton("View Librarian");
btnViewLibrarian.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
ViewLibrarian.main(new String[]{});
}
});
btnViewLibrarian.setFont(new Font("Tahoma", Font.PLAIN, 15));
JButton btnDeleteLibrarian = new JButton("Delete Librarian");
btnDeleteLibrarian.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
DeleteLibrarian.main(new String[]{});
frame.dispose();
}
});
btnDeleteLibrarian.setFont(new Font("Tahoma", Font.PLAIN, 15));
JButton btnLogout = new JButton("Logout");
btnLogout.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
Library.main(new String[]{});
frame.dispose();
}
});
btnLogout.setFont(new Font("Tahoma", Font.PLAIN, 15));
GroupLayout gl_contentPane = new GroupLayout(contentPane);
gl_contentPane.setHorizontalGroup(
gl_contentPane.createParallelGroup(Alignment.TRAILING)
.addGroup(gl_contentPane.createSequentialGroup()
.addContainerGap(150, Short.MAX_VALUE)
.addComponent(lblAdminSection, GroupLayout.PREFERRED_SIZE, 151, GroupLayout.PREFERRED_SIZE)
.addGap(123))
.addGroup(Alignment.LEADING, gl_contentPane.createSequentialGroup()
.addGap(134)
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addComponent(btnLogout, GroupLayout.PREFERRED_SIZE, 181, GroupLayout.PREFERRED_SIZE)
.addComponent(btnDeleteLibrarian, GroupLayout.PREFERRED_SIZE, 181, GroupLayout.PREFERRED_SIZE)
.addComponent(btnViewLibrarian, GroupLayout.PREFERRED_SIZE, 181, GroupLayout.PREFERRED_SIZE)
.addComponent(btnNewButton, GroupLayout.PREFERRED_SIZE, 181, GroupLayout.PREFERRED_SIZE))
.addContainerGap(109, Short.MAX_VALUE))
);
gl_contentPane.setVerticalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addComponent(lblAdminSection, GroupLayout.PREFERRED_SIZE, 40, GroupLayout.PREFERRED_SIZE)
.addGap(11)
.addComponent(btnNewButton, GroupLayout.PREFERRED_SIZE, 49, GroupLayout.PREFERRED_SIZE)
.addGap(18)
.addComponent(btnViewLibrarian, GroupLayout.PREFERRED_SIZE, 49, GroupLayout.PREFERRED_SIZE)
.addGap(18)
.addComponent(btnDeleteLibrarian, GroupLayout.PREFERRED_SIZE, 49, GroupLayout.PREFERRED_SIZE)
.addGap(18)
.addComponent(btnLogout, GroupLayout.PREFERRED_SIZE, 49, GroupLayout.PREFERRED_SIZE)
.addContainerGap(21, Short.MAX_VALUE))
);
contentPane.setLayout(gl_contentPane);
}
}
output:
LibrarianLogin.java
package librarymanagementssystem;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import java.awt.Font;
import java.awt.Color;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JPasswordField;
public class LibrarianLogin extends JFrame {
static LibrarianLogin frame;
private JPanel contentPane;
private JTextField textField;
private JPasswordField passwordField;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
frame = new LibrarianLogin();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public LibrarianLogin() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
JLabel lblAdminLoginForm = new JLabel("Librarian Login Form");
lblAdminLoginForm.setForeground(Color.GRAY);
lblAdminLoginForm.setFont(new Font("Tahoma", Font.PLAIN, 18));
JLabel lblEnterName = new JLabel("Enter Name:");
JLabel lblEnterPassword = new JLabel("Enter Password:");
textField = new JTextField();
textField.setColumns(10);
JButton btnLogin = new JButton("Login");
btnLogin.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String name=textField.getText();
String password=String.valueOf(passwordField.getPassword());
//System.out.println(name+" "+password);
if(name.equals("kiran")&&password.equals("abcd")){
LibrarianSuccess.main(new String[]{});
frame.dispose();
}else{
JOptionPane.showMessageDialog(LibrarianLogin.this, "Sorry, Username or Password Error","Login Error!", JOptionPane.ERROR_MESSAGE);
textField.setText("");
passwordField.setText("");
}
}
});
passwordField = new JPasswordField();
GroupLayout gl_contentPane = new GroupLayout(contentPane);
gl_contentPane.setHorizontalGroup(
gl_contentPane.createParallelGroup(Alignment.TRAILING)
.addGroup(gl_contentPane.createSequentialGroup()
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(124)
.addComponent(lblAdminLoginForm))
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(19)
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addComponent(lblEnterName)
.addComponent(lblEnterPassword))
.addGap(47)
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING, false)
.addComponent(passwordField)
.addComponent(textField, GroupLayout.DEFAULT_SIZE, 172, Short.MAX_VALUE))))
.addContainerGap(107, Short.MAX_VALUE))
.addGroup(gl_contentPane.createSequentialGroup()
.addContainerGap(187, Short.MAX_VALUE)
.addComponent(btnLogin, GroupLayout.PREFERRED_SIZE, 86, GroupLayout.PREFERRED_SIZE)
.addGap(151))
);
gl_contentPane.setVerticalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addComponent(lblAdminLoginForm)
.addGap(26)
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(lblEnterName)
.addComponent(textField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(28)
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(lblEnterPassword)
.addComponent(passwordField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(18)
.addComponent(btnLogin, GroupLayout.PREFERRED_SIZE, 37, GroupLayout.PREFERRED_SIZE)
.addContainerGap(80, Short.MAX_VALUE))
);
contentPane.setLayout(gl_contentPane);
}
}
output:
LibrarianSuccess.java
package librarymanagementssystem;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JLabel;
import java.awt.Font;
import java.awt.Color;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class LibrarianSuccess extends JFrame {
static LibrarianSuccess frame;
private JPanel contentPane;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
frame = new LibrarianSuccess();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public LibrarianSuccess() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 433);
contentPane = new JPanel();
contentPane.setForeground(Color.GRAY);
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
JLabel lblLibrarianSection = new JLabel("Librarian Section - JavaTpoint");
lblLibrarianSection.setFont(new Font("Tahoma", Font.PLAIN, 22));
JButton btnNewButton = new JButton("Add Books");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
frame.dispose();
}
});
btnNewButton.setFont(new Font("Tahoma", Font.PLAIN, 13));
JButton btnViewBooks = new JButton("View Books");
btnViewBooks.setFont(new Font("Tahoma", Font.PLAIN, 13));
JButton btnIssueBook = new JButton("Issue Book");
btnIssueBook.setFont(new Font("Tahoma", Font.PLAIN, 13));
JButton btnViewIssuedBooks = new JButton("View Issued Books");
btnViewIssuedBooks.setFont(new Font("Tahoma", Font.PLAIN, 13));
JButton btnReturnBook = new JButton("Return Book");
btnReturnBook.setFont(new Font("Tahoma", Font.PLAIN, 13));
JButton btnLogout = new JButton("Logout");
btnLogout.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Library.main(new String[]{});
frame.dispose();
}
});
btnLogout.setFont(new Font("Tahoma", Font.PLAIN, 13));
GroupLayout gl_contentPane = new GroupLayout(contentPane);
gl_contentPane.setHorizontalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(Alignment.TRAILING, gl_contentPane.createSequentialGroup()
.addContainerGap(81, Short.MAX_VALUE)
.addComponent(lblLibrarianSection)
.addGap(54))
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(132)
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addComponent(btnLogout, GroupLayout.PREFERRED_SIZE, 191, GroupLayout.PREFERRED_SIZE)
.addComponent(btnReturnBook, GroupLayout.PREFERRED_SIZE, 191, GroupLayout.PREFERRED_SIZE)
.addComponent(btnViewIssuedBooks, GroupLayout.PREFERRED_SIZE, 191, GroupLayout.PREFERRED_SIZE)
.addComponent(btnIssueBook, GroupLayout.PREFERRED_SIZE, 191, GroupLayout.PREFERRED_SIZE)
.addComponent(btnViewBooks, GroupLayout.PREFERRED_SIZE, 191, GroupLayout.PREFERRED_SIZE)
.addComponent(btnNewButton, GroupLayout.PREFERRED_SIZE, 191, GroupLayout.PREFERRED_SIZE))
.addContainerGap(101, Short.MAX_VALUE))
);
gl_contentPane.setVerticalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addContainerGap()
.addComponent(lblLibrarianSection)
.addGap(18)
.addComponent(btnNewButton, GroupLayout.PREFERRED_SIZE, 37, GroupLayout.PREFERRED_SIZE)
.addGap(18)
.addComponent(btnViewBooks, GroupLayout.PREFERRED_SIZE, 37, GroupLayout.PREFERRED_SIZE)
.addGap(18)
.addComponent(btnIssueBook, GroupLayout.PREFERRED_SIZE, 37, GroupLayout.PREFERRED_SIZE)
.addGap(18)
.addComponent(btnViewIssuedBooks, GroupLayout.PREFERRED_SIZE, 37, GroupLayout.PREFERRED_SIZE)
.addGap(18)
.addComponent(btnReturnBook, GroupLayout.PREFERRED_SIZE, 37, GroupLayout.PREFERRED_SIZE)
.addGap(18)
.addComponent(btnLogout, GroupLayout.PREFERRED_SIZE, 37, GroupLayout.PREFERRED_SIZE)
.addContainerGap(16, Short.MAX_VALUE))
);
contentPane.setLayout(gl_contentPane);
}
}
output:
0 Comments