bank management system in java

introduction
The Bank Management System is a full-fledged application for simulating day-to-day banking operations. It supports features such as account creation, balance inquiry, cash deposits, withdrawals, fund transfers, and transaction logging.
Admins can view reports and approve new accounts. The system ensures data integrity and simulates real-time transactions in a secure environment. With a modern GUI, it provides a realistic banking experience.
This project is a solid example of core Java skills, file management, multi-user systems, and secure transaction handling.
This project provides a complete workflow for managing personal bank accounts, offering an interactive experience that mirrors actual banking procedures. It ensures accuracy, data integrity, and user security, while also showcasing practical implementation of file handling and multi-user systems.
Key Functionalities:
Account Creation: Users can register new bank accounts with essential details like name, address, contact number, and initial deposit.
Balance Inquiry: Users can check their current account balance at any time.
Cash Deposit: Allows secure addition of funds to the user’s account.
Cash Withdrawal: Users can withdraw money, with checks for sufficient balance.
Fund Transfers: Users can send money to another account within the system using account numbers.
Transaction History: Each deposit, withdrawal, or transfer is recorded and can be viewed in a transaction log.
For Admins:
Approve New Accounts: Admins can review and activate pending account creation requests.
View Reports: Admins can access summaries such as total active accounts, total deposits, and logs of daily transactions.
Monitor Activity: Admins can monitor suspicious transactions and view user account statuses.
Technical Features:
File Handling or Database Storage: All user and transaction data can be stored using file I/O operations or integrated with a database for persistent storage.
Data Validation: Every user action (like withdrawals and transfers) is validated for correctness and safety.
Multi-user System: Supports different roles (e.g., customer and admin) with appropriate access controls.
Secure Transactions: The application mimics real-time processing and includes safeguards against unauthorized or incorrect actions.
User-Friendly GUI: The GUI is built with Java Swing, including buttons, tables, dropdowns, and forms for interactive user experience.
steps to create blood bank management system
-
Define accounts, transactions, users.
-
Design secure login and account management GUI.
-
Create Account, Transaction, Customer classes.
-
Implement deposit, withdraw, transfer.
-
Store data securely (DB preferred).
-
Add transaction logs and reports.
-
Test all banking operations.
-
Add multi-user roles.
-
Document thoroughly.
-
Package and deploy.
code explanation
1.Donor
Class
class Donor {
String name, bloodGroup, contact;
Donor(String name, String bloodGroup, String contact) {
this.name = name;
this.bloodGroup = bloodGroup;
this.contact = contact;
}
}
Represents a donor with 3 fields:
name
,bloodGroup
, andcontact
.
2.BloodBankSystem
Class (Main GUI Application)
public class BloodBankSystem extends JFrame {
Extends
JFrame
to create a main window for the application.Contains the GUI, donor list, and event logic.
3.GUI Layout (Components)
1. Top Panel (North):
JLabel title = new JLabel("Blood Bank Management System", JLabel.CENTER);
Displays the app title in red and bold font.
2. Left Panel (West) – Form Panel:
Contains form inputs:
tfName
– Text field for namecbBloodGroup
– Dropdown with blood groupstfContact
– Text field for contactButtons:
Add Donor
Search by Group
3. Center Panel:
donorTable = new JTable(tableModel);
Displays donor list using a
JTable
.
4. Bottom Panel (South):
tfSearch
– For entering blood group to searchShow All
andDelete Selected
buttons
Event Handling
btnAdd
– Add Donor
addDonor()
Gets name, blood group, and contact
Validates that fields are not empty
Adds donor to
donorList
Reloads table
btnSearch
– Search by Blood Group
searchByBloodGroup()
Searches and filters donor list by matching blood group
Updates the table with matching results
✅ btnDelete
– Delete Selected
deleteSelected()
Gets selected row in table
Removes corresponding donor from
donorList
Reloads table
btnShowAll
– Show All Donors
loadTable()
Displays all donors in the table
Sample Donor Data:
donorList.add(new Donor("John Doe", "A+", "9876543210"));
donorList.add(new Donor("Jane Smith", "O-", "9123456789"));
Pre-added sample records for testing UI
main()
Method
public static void main(String[] args) {
SwingUtilities.invokeLater(() -> new BloodBankSystem().setVisible(true));
}
Launches the GUI on the Event Dispatch Thread.
source code
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;
class Donor {
String name, bloodGroup, contact;
Donor(String name, String bloodGroup, String contact) {
this.name = name;
this.bloodGroup = bloodGroup;
this.contact = contact;
}
}
public class BloodBankSystem extends JFrame {
private ArrayList donorList = new ArrayList();
private JTextField tfName, tfContact, tfSearch;
private JComboBox cbBloodGroup;
private JTable donorTable;
private DefaultTableModel tableModel;
public BloodBankSystem() {
setTitle("Blood Bank Management System");
setSize(750, 500);
setLocationRelativeTo(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setLayout(new BorderLayout());
// --- Top Panel Title ---
JLabel title = new JLabel("Blood Bank Management System", JLabel.CENTER);
title.setFont(new Font("Segoe UI", Font.BOLD, 22));
title.setForeground(Color.RED);
title.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
add(title, BorderLayout.NORTH);
// --- Form Panel (Left) ---
JPanel formPanel = new JPanel();
formPanel.setLayout(new GridLayout(8, 1, 5, 5));
formPanel.setBorder(BorderFactory.createEmptyBorder(10, 20, 10, 20));
formPanel.setBackground(new Color(255, 240, 240));
tfName = new JTextField();
tfContact = new JTextField();
cbBloodGroup = new JComboBox(new String[]{"A+", "A-", "B+", "B-", "AB+", "AB-", "O+", "O-"});
tfSearch = new JTextField();
JButton btnAdd = new JButton("Add Donor");
JButton btnSearch = new JButton("Search by Group");
JButton btnDelete = new JButton("Delete Selected");
JButton btnShowAll = new JButton("Show All");
formPanel.add(new JLabel("Name:"));
formPanel.add(tfName);
formPanel.add(new JLabel("Blood Group:"));
formPanel.add(cbBloodGroup);
formPanel.add(new JLabel("Contact:"));
formPanel.add(tfContact);
formPanel.add(btnAdd);
formPanel.add(btnSearch);
add(formPanel, BorderLayout.WEST);
// --- Table Panel (Center) ---
tableModel = new DefaultTableModel(new String[]{"Name", "Blood Group", "Contact"}, 0);
donorTable = new JTable(tableModel);
JScrollPane scrollPane = new JScrollPane(donorTable);
add(scrollPane, BorderLayout.CENTER);
// --- Bottom Panel ---
JPanel bottomPanel = new JPanel();
bottomPanel.setBackground(new Color(255, 240, 240));
bottomPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 20, 10));
bottomPanel.add(new JLabel("Search Blood Group:"));
bottomPanel.add(tfSearch);
bottomPanel.add(btnShowAll);
bottomPanel.add(btnDelete);
add(bottomPanel, BorderLayout.SOUTH);
// --- Event Listeners ---
btnAdd.addActionListener(e -> addDonor());
btnSearch.addActionListener(e -> searchByBloodGroup());
btnDelete.addActionListener(e -> deleteSelected());
btnShowAll.addActionListener(e -> loadTable());
// Sample data
donorList.add(new Donor("John Doe", "A+", "9876543210"));
donorList.add(new Donor("Jane Smith", "O-", "9123456789"));
loadTable();
}
private void addDonor() {
String name = tfName.getText().trim();
String contact = tfContact.getText().trim();
String blood = cbBloodGroup.getSelectedItem().toString();
if (name.isEmpty() || contact.isEmpty()) {
JOptionPane.showMessageDialog(this, "Please enter all details.");
return;
}
donorList.add(new Donor(name, blood, contact));
loadTable();
tfName.setText("");
tfContact.setText("");
}
private void searchByBloodGroup() {
String bg = tfSearch.getText().trim().toUpperCase();
if (bg.isEmpty()) {
JOptionPane.showMessageDialog(this, "Enter blood group to search.");
return;
}
tableModel.setRowCount(0);
for (Donor d : donorList) {
if (d.bloodGroup.equalsIgnoreCase(bg)) {
tableModel.addRow(new Object[]{d.name, d.bloodGroup, d.contact});
}
}
}
private void deleteSelected() {
int row = donorTable.getSelectedRow();
if (row == -1) {
JOptionPane.showMessageDialog(this, "Select a row to delete.");
return;
}
String name = tableModel.getValueAt(row, 0).toString();
donorList.removeIf(d -> d.name.equals(name));
loadTable();
}
private void loadTable() {
tableModel.setRowCount(0);
for (Donor d : donorList) {
tableModel.addRow(new Object[]{d.name, d.bloodGroup, d.contact});
}
}
public static void main(String[] args) {
SwingUtilities.invokeLater(() -> new BloodBankSystem().setVisible(true));
}
}
output
