Bill_Generator_Mini_Project_Report
Bill_Generator_Mini_Project_Report
Chapter 1: Introduction
The Bill Generator Application is a user-friendly Java-based software developed using
the Swing framework. It simplifies the process of generating bills by allowing users to
select items, specify quantities, and calculate the total cost. The system is designed to
automate manual billing processes, making it efficient for small businesses or individual
users. The application retrieves item data from a database and presents it in a graphical
user interface (GUI), making it easier for non-technical users to generate and save bills.
This project addresses the common challenges of manual bill creation, such as human
errors in calculations, time consumption, and data entry. By utilizing Java's robust Swing
library and database connectivity, the application ensures reliable and accurate bill
generation.
Chapter 3: Modules
3.1 Home Page (HomePage.java)
The Home Page is the introductory screen of the application. It displays a welcome
message and includes a button that allows users to navigate to the bill generation screen.
Features: Welcome message displayed at the center. Button to navigate to the bill
generation page.
Page 1
3.2 Bill Page (BillPage.java)
The Bill Page is the core component of the application where users can select items,
specify quantities, and see the calculated price. This page displays a table that
dynamically updates as the user adds items.
Purpose: Enable users to select items, specify quantities, and calculate the total price.
Features: Dropdown menus for item selection and quantity. Automatic price update based
on the selected item. Button to generate and save the final bill to a text file.
Features: Text area showing selected items and their corresponding prices. Button to
navigate back to the Home Page.
Page 2
Chapter 4: Database
Database Screenshot
Page 3
Chapter 5: Implementation (Complete Source Code)
5.1 BillGeneratorApp.java
package billgeneratorapp;
import javax.swing.*;
SwingUtilities.invokeLater(() -> {
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
});
5.2 BillPage.java
package billgeneratorapp;
Page 4
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
this.mainFrame = mainFrame;
setLayout(new BorderLayout());
Page 5
setBackground(new Color(255, 250, 205)); // Lemon Chiffon background
fetchItems();
inputPanel.add(itemComboBox);
inputPanel.add(quantityComboBox);
inputPanel.add(new JLabel("Price:"));
inputPanel.add(priceField);
addButton.setForeground(Color.WHITE);
addButton.addActionListener(new AddItemAction());
Page 6
inputPanel.add(addButton);
generateButton.setForeground(Color.WHITE);
generateButton.addActionListener(new GenerateBillAction());
inputPanel.add(generateButton);
add(inputPanel, BorderLayout.NORTH);
Page 7
while (rs.next()) {
itemComboBox.addItem(itemName);
itemPrices.add(itemAmount);
} catch (SQLException e) {
priceField.setText(String.valueOf(price));
@Override
Page 8
int quantity = (Integer) quantityComboBox.getSelectedItem();
double price;
try {
price = Double.parseDouble(priceField.getText());
return;
@Override
double grandTotal = 0;
Page 9
double total = (Double) tableModel.getValueAt(i, 3);
grandTotal += total;
writer.write(billContent.toString());
5.3 Homepage.java
package billgeneratorapp;
import javax.swing.*;
import java.awt.*;
Page 10
class HomePage extends JPanel {
setLayout(new BorderLayout());
startButton.setForeground(Color.WHITE);
add(welcomeLabel, BorderLayout.CENTER);
add(startButton, BorderLayout.SOUTH);
5.4 MainFrame.java
package billgeneratorapp;
import javax.swing.*;
import java.awt.*;
Page 11
class MainFrame extends JFrame {
public MainFrame() {
setTitle("Bill Generator");
setSize(400, 300);
setLayout(new CardLayout());
5.5 SummaryPage.java
package billgeneratorapp;
import javax.swing.*;
import java.awt.*;
Page 12
public SummaryPage(MainFrame mainFrame, String item, int quantity, double total) {
setLayout(new BorderLayout());
summaryArea.setEditable(false);
summaryArea.setBackground(Color.WHITE);
backButton.setForeground(Color.WHITE);
backButton.addActionListener(e -> {
mainFrame.remove(this);
mainFrame.showPage("Home");
});
add(summaryArea, BorderLayout.CENTER);
add(backButton, BorderLayout.SOUTH);
}}
Page 13
Chapter 6: Results
6.1 Step 1:
6.2 Step 2:
Page 14
6.3 Step 3:
6.4 Step 4:
Page 15
6.5 Step 5:
Chapter 7: Conclusion
The Bill Generator Application successfully simplifies the bill generation process by
automating item selection, quantity specification, and price calculation. The application is
easy to use, with an intuitive GUI and reliable database connectivity for fetching item
data. The system effectively reduces manual errors and increases efficiency, making it
ideal for small businesses or personal use.
Chapter 8: References
1. Oracle Java Swing Documentation
3. Stack Overflow
Page 16