FinalCSSE Project Report
FinalCSSE Project Report
1 Introduction 3
1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
3 Interface Snapshots 15
3.1 LogIn page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.2 Frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.3 SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4 Conclusion 18
4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
4.2 Practical Implications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
4.3 Scope of Future Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
1
Abstract
The Money Handler System is a Java-based application that manages financial trans-
actions by generating, adding, and updating records in real-time. It allows users to
securely add their names and product details and saves the information in a local
database. The system is designed using Java Swing and MySQL database. The project
includes a login page and a frame that collects and sends information to the server. The
purpose of this system is to hold information about the product and it is easy to use
and interact with. Overall, the Money Handler System is a user-friendly and efficient
way to manage financial records.
Figure 1: Project
2
Chapter 1
Introduction
1.1 Introduction
Money Handler is a Java-based system designed to simplify the process of managing
financial records for products. The system uses Java Swing to create a user-friendly
interface, and MySQL database to store and manage data. The purpose of the system
is to hold information about different products and provide an easy-to-use platform for
users to interact with the data.
The system includes a login page for user authentication, and a frame for entering and
sending product information to the server. Money Handler is designed to be efficient,
secure, and easy to use, allowing users to store, manage, and update financial records
easily.
1.2 Objectives
The core objective of this project is to design a system with java swing and SQL for
learning purposes but there are more. [5] [4]
• To streamline the process of managing financial records for products, making it
more efficient and less time-consuming.
• To provide a user-friendly interface that allows users to easily enter and retrieve
product information. To improve data accuracy and reduce errors in financial
records by providing a centralized database for storing and managing product
information.
• To enhance data security by implementing user authentication and access con-
trol features, ensuring that only authorized users can access and modify product
information.
• To provide real-time updating of financial records, making it easy for users to keep
track of changes in product information over time.
• To improve decision-making by providing accurate and up-to-date financial infor-
mation that can be used to inform business strategies and decisions.
• To reduce the risk of data loss by providing a reliable backup and recovery system
that ensures that product information is not lost due to system failures or other
issues.
3
Chapter 2
2.2 Implementation
2.2.1 LogIn.Class
package handlersys;
//import javax.swing.ImageIcon;
//import javax.swing.JFrame;
import java.awt.Color;
import java.awt.Container;
import java.awt.Cursor;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
4
private JLabel userlabel1, userlabel2, userlabel3;
private JLabel imgLabel;
private JTextField tf1;
// private JTextField tf2;
private JPasswordField passf;
private JButton btn1, btn2;
private Cursor cursorhand;
loginframe() { // constructor
initComponents();
}
// Creating JLabel
userlabel1 = new JLabel(); // created JLabel object
userlabel2 = new JLabel(" To Begin Enter your Username: "); // set text Jlabel
userlabel3 = new JLabel(" Enter your Password: ");
userlabel1.setText(
" Welcome to The World’s Best Personal Fiancial App. :,)"
);
5
tf1 = new JTextField();
tf1.setFont(h2f);
// tf1.setCursor(cursor2);
// tf2 = new JTextField();
passf = new JPasswordField();
passf.setEchoChar(’*’);
passf.setFont(h3f);
// Reset Password
btn1 = new JButton("Reset Password");
btn1.setFont(h4f);
btn1.setForeground(Color.BLACK);
btn1.setBackground(Color.WHITE);
btn1.setCursor(cursorhand);
// Set Account
btn2 = new JButton("Create new Account");
btn2.setFont(h4f);
btn2.setForeground(Color.BLACK);
btn2.setBackground(Color.WHITE);
btn2.setCursor(cursorhand);
// setting Location
userlabel1.setBounds(20, 40, 637, 30); // setting location of the Jlabel textfield
userlabel2.setBounds(50 + 85, 310 + 60, 290, 30);
userlabel3.setBounds(50 + 85, 350 + 60, 290, 30);
imgLabel.setBounds(0, 0, cover.getIconWidth(), cover.getIconHeight());
// imgLabel.setBounds(10, 10, cover.getIconWidth(),cover.getIconHeight());
// imgLabel.setBounds(0, 0, 690,280);
tf1.setBounds(355 + 85, 310 + 60, 290, 30);
tf1.setHorizontalAlignment(JTextField.CENTER);
passf.setBounds(355 + 85, 350 + 60, 290, 30);
passf.setHorizontalAlignment(JPasswordField.CENTER);
// tf2.setBounds(355 + 85, 350 + 60, 290, 30);
// tf2.setHorizontalAlignment(JTextField.CENTER);
btn1.setBounds(20, 100, 160, 25);
btn2.setBounds(190, 100, 190, 25);
// action listener
tf1.addActionListener(
new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String S = tf1.getText();
if (S.isEmpty()) {
JOptionPane.showMessageDialog(null, "Please Enter name");
} else {
passf.requestFocusInWindow();
}
}
}
);
passf.addActionListener(
new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
char[] passwordChars = passf.getPassword();
String S1 = new String(passwordChars);
String S = tf1.getText();
if (S1.isEmpty() || S.isEmpty()) {
6
JOptionPane.showMessageDialog(
null,
"Please Enter Password or Username"
);
} else if (S.equals("Sabbir") && S1.equals("abc")) {
dispose();
frame1 frame = new frame1();
frame.setVisible(true);
} else {
JOptionPane.showMessageDialog(
null,
"Incorrect password or Username"
);
}
}
}
);
btn1.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(null, "You resetted your password");
}
}
);
btn2.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(null, "Created Account");
}
}
);
C.add(imgLabel);
C.add(tf1);
C.add(passf);
// C.add(tf2);
7
2.2.2 Algorithm
2.2.3 Frame1.class
package handlersys;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
8
private JLabel titleLabel, NameLabel, productlabel, pricelabel, idlabel;
private JTextField nametf, pricetf, idtf, producttf;
private JButton addButton, deleteButton, clearButton, updateButton, SaveButton;
private Font h1f, h2f;
private JTable table;
private JScrollPane scroll;
private DefaultTableModel model;
private String[] columns = {"Name", "Product", "Price", "Id"};
private String[] rows = new String[4];
frame1() { // constructor
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(780, 690);
this.setTitle("Money Handler System (BETA)");
this.setResizable(false);
this.setLocationRelativeTo(null);
initComponents2();
}
9
pricelabel = new JLabel(" Price");
pricelabel.setBounds(10 + 40, 180, 140, 30);
pricelabel.setFont(h2f);
pricelabel.setForeground(Color.WHITE);
C.add(pricelabel);
10
ResultSet resultSet = null;
try {
// Register JDBC driver
Class.forName("com.mysql.cj.jdbc.Driver");
// Open connection
String dbUrl = "jdbc:mysql://localhost/moneydb";
String dbUser = "root";
String dbPass = "";
connection = DriverManager.getConnection(dbUrl, dbUser, dbPass);
// Execute a query
String sql = "SELECT * FROM ‘moneytable‘";
statement = connection.createStatement();
resultSet = statement.executeQuery(sql);
rows[0] = name;
rows[1] = product;
rows[2] = Integer.toString(price);
rows[3] = id;
model.addRow(rows);
addButton.addActionListener(this);
deleteButton.addActionListener(this);
updateButton.addActionListener(this);
clearButton.addActionListener(this);
SaveButton.addActionListener(this);
table.addMouseListener(
new MouseAdapter() {
11
public void mouseClicked(MouseEvent e) {
int numberofrow = table.getSelectedRow();
String nameString = model.getValueAt(numberofrow, 0).toString();
String producString = model.getValueAt(numberofrow, 1).toString();
String priceString = model.getValueAt(numberofrow, 2).toString();
String idString = model.getValueAt(numberofrow, 3).toString();
nametf.setText(nameString);
producttf.setText(producString);
pricetf.setText(priceString);
idtf.setText(idString);
}
}
);
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == addButton) {
rows[0] = nametf.getText();
rows[1] = producttf.getText();
rows[2] = pricetf.getText();
rows[3] = idtf.getText();
model.addRow(rows);
} else if (e.getSource() == SaveButton) {
try {
JTableSync.replaceTable(table);
JOptionPane.showMessageDialog(null, "Saved Successful!!");
}
} else if (e.getSource() == clearButton) {
nametf.setText("");
producttf.setText("");
pricetf.setText("");
idtf.setText("");
} else if (e.getSource() == deleteButton) {
int numberofrow = table.getSelectedRow();
if (numberofrow >= 0) {
model.removeRow(numberofrow);
} else {
JOptionPane.showMessageDialog(null, "You didn’t selected anything!");
}
} else if (e.getSource() == updateButton) {
int numberOfrow = table.getSelectedRow();
12
public class JTableSync {
// Insert the new data from the JTable into the table
String insertQuery = "INSERT INTO " + TABLE_NAME + " (Name, Product,
Price, ID) VALUES (?, ?, ?, ?)";
try (PreparedStatement insertStatement =
conn.prepareStatement(insertQuery)) {
for (int i = 0; i < model.getRowCount(); i++) {
String name = model.getValueAt(i, 0).toString();
String product = model.getValueAt(i, 1).toString();
double price = Double.parseDouble(model.getValueAt(i,
2).toString());
String id = model.getValueAt(i, 3).toString();
insertStatement.setString(1, name);
insertStatement.setString(2, product);
insertStatement.setDouble(3, price);
insertStatement.setString(4, id);
insertStatement.executeUpdate();
}
}
}
}
}
2.2.4 Algorithm
13
Algorithm 2: Search using thread
Input: N
Result: Found by Thread No: ” index id”. The index is ”index number”
1 Start ;
2 Import necessary libraries and packages.;
3 Create a class named frame1 that extends JFrame and implements
ActionListener.;
4 Define instance variables to hold GUI components such as labels, text fields,
buttons,;
5 and a table.;
6 Define a constructor for the frame1 class that sets various properties of the
frame, such as its size and title, and calls a method named initComponents2().;
7 Define a method named initComponents2() that creates the GUI components,
sets their properties, and adds them to the frame.;
8 Use a layout manager (in this case, null layout) to manually position the GUI
components within the frame.;
9 Define an action listener for the buttons that performs the desired database
operation (add, delete, clear, update).;
10 Create a JTable and a DefaultTableModel and set the latter as the model for
the former.;
11 Add the JTable to a JScrollPane and add the JScrollPane to the frame.;
12 Connect to a database using JDBC and perform desired database operations
(insert, delete, update, select) using SQL queries.;
13 Populate the JTable with data retrieved from the database.;
14 The code connects to a database using JDBC.;
15 The code executes a SELECT query to retrieve data from the database and
populates a JTable with the data.;
16 The code defines an event listener for various buttons (add, delete, update,
clear) that performs the desired database operation.;
17 When the Save button is clicked, the code uses JTableSync to replace the data
in the database table with the data in the JTable.;
18 JTableSync truncates the table and inserts the new data from the JTable into
the table. The code defines a class named frame1 that extends JFrame and
implements ActionListener. The code defines instance variables to hold GUI
components such as labels, text fields, buttons, and a table.;
19 The code defines a constructor for the frame1 class that sets various properties
of the frame, such as its size and title, and calls a method named
initComponents2().;
20 The code defines a method named initComponents2() that creates the GUI
components, sets their properties, and adds them to the frame.;
21 The code uses a layout manager (in this case, null layout) to manually position
the GUI components within the frame.;
22 The code defines an action listener for the table that sets the text fields to the
values of the selected row when the row is clicked.;
23 The code defines an actionPerformed() method that performs the desired
database operation when a button is clicked.;
24 The code defines a JTableSync class that replaces the data in the database table
with the data in the JTable.;
25 End ;
14
Chapter 3
Interface Snapshots
The login page is an important security feature that ensures the safety and privacy
of user data within the system. prompts users to enter their username and password,
which are authenticated against a database of authorized users.
3.2 Frame
The frame is the main user interface component that provides a graphical user interface
for the Money Handler System. The frame contains various GUI components such as
labels, text fields, buttons, and a table, which allow users to interact with the system and
manage financial transactions. The frame is implemented as a class named ”frame1”
that extends the JFrame class and implements the ActionListener interface to respond
to user actions.
15
The frame provides a window that displays the system’s functionality, and the user
can interact with the system through the GUI components on the frame. The frame al-
lows the user to add, delete, update, and clear financial transactions, and these actions
are performed by event listeners that respond to user actions on the GUI components.
Additionally, the frame is designed using a layout manager that allows the GUI com-
ponents to be positioned and arranged within the frame. [6]
3.3 SQL
SQL (Structured Query Language) is used to manage the database that stores the
financial records for the Money Handler System. SQL is a standard language for man-
aging relational databases and is commonly used for data manipulation, retrieval, and
management.
The SQL database is used to store and manage financial transaction records, includ-
ing information such as the product name, date of purchase, price, and other related
details. The SQL database allows the system to store and manage a large volume of
financial records efficiently and securely.
16
The SQL database is accessed through Java Database Connectivity (JDBC), which
provides the ability to connect to and interact with the database from within the Java
application. The JDBC API allows Java applications to send SQL statements to the
database and retrieve data for processing within the application. [2]
17
Chapter 4
Conclusion
4.1 Introduction
The Money Handler System is an innovative application that simplifies the task of
managing financial records. The system is designed to allow users to add, delete, and
update financial transactions in real-time. The project is developed using Java Swing
and MySQL database, which makes it easy to use and interact with. The system
includes a login page and a frame that collects and sends information to the server.
The application is user-friendly and efficient, making it an ideal solution for financial
management tasks.
18
In conclusion, the Money Handler System is an effective solution for managing finan-
cial records with ease and efficiency. The system’s user-friendly interface and advanced
features make it an ideal choice for individuals, small businesses, and organizations.
With the potential for future expansion and improvement, the Money Handler System
offers practical implications that can help users make better financial decisions. This
project has highlighted the benefits of using Java and MySQL databases in develop-
ing such systems. As such, the Money Handler System is a valuable tool for financial
management that can save time and improve financial record keeping.
19
Bibliography
20