Project Report
Project Report
SUBMITTED TO
SUBMITTED BY
MARIA BANO
BSSE-2-(A)-MORNING
NUML-S21-18375
COURSE
Topic
Project Report
Project About:
Grocery Store:
The project consists of total of 3 frames. The first frame is the login frame where
the user will enter his/her credentials to login into system. The second frame is the
main page of Grocery Store where user will select which item he wants by using
different menus as given. The third frame of grocery store includes a table where al
the items will be stored. The frame also has a customer name, address and phone
number fields where the user will enter the data in order to get his order,
Frame 1:
Code:
package oopproject;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.table.DefaultTableModel;
public int a;
public String b;
f.setSize(1020, 600);
f.setLayout(null);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//panel for login
p1.setBackground(Color.lightGray);
p1.setLayout(null);
p2.setBackground(Color.lightGray);
p2.setLayout(null);
l3.setIcon(i);
p2.add(l3);
l4.setIcon(i2);
l4.setBounds(70, 50, 70, 70);
p1.add(l4);
l5.setFont(new Font("Arial",Font.BOLD,25));
l5.setBounds(150,30,200,80);
p1.add(l5);
l6.setFont(new Font("Arial",Font.BOLD,12));
l6.setBounds(150,50,200,80);
p1.add(l6);
l1.setBounds(70,160,80,80);
l1.setFont(new Font("Arial",Font.BOLD,14));
l1.setForeground(Color.darkGray);
t1=new JTextField();
t1.setBackground(Color.lightGray);
t1.setBorder(BorderFactory.createLineBorder(Color.white));
t1.setBounds(150, 190, 250, 25);
l2.setBounds(70,204,80,80);
l2.setFont(new Font("Arial",Font.BOLD,14));
l2.setForeground(Color.darkGray);
t2=new JPasswordField();
t2.setBorder(BorderFactory.createLineBorder(Color.white));
t2.setBackground(Color.lightGray);
//login button.
b1=new JButton("Login");
b1.setFocusable(false);
b1.setBorder(BorderFactory.createLineBorder(Color.white));
b1.setBackground(Color.white);
b1.addActionListener(new OopProject());
b2=new JButton(" Create an account");
b2.addActionListener(new OopProject());
b2.setFocusable(false);
b2.setBorder(BorderFactory.createLineBorder(Color.white));
b2.setBackground(Color.white);
f.setResizable(false);
f.setVisible(true);
f.add(p1);
f.add(p2);
p1.add(l1);
p1.add(t1);
p1.add(l2);
p1.add(t2);
p1.add(b1);
p1.add(b2);
}
@Override
if(e.getSource().equals(b2)){
Connection con;
PreparedStatement ps;
try {
Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
con = DriverManager.getConnection("jdbc:ucanaccess://F:\\login.accdb");
ps.setString(1, t1.getText());
ps.setString(2, t2.getText());
ps.executeUpdate();
}
}
if(e.getSource().equals(b1)){
if(t1.getText().equals("")&&t2.getText().equals("")){
else{
if(len.length()<4){
else{
try{
Connection co;
PreparedStatement pst;
ResultSet rs;
Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
co = DriverManager.getConnection("jdbc:ucanaccess://F:\\login.accdb");
rs=pst.executeQuery();
if(rs.next()){
f.setVisible(false);
Code Screenshot:
Frame 2:
Code:
f2.setSize(1366, 768);
f2.setLayout(null);
f2.setVisible(true);
f2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
p.setBounds(0,0,1366,768);
p.setBackground(Color.lightGray);
p.setIcon(pimg);
f2.add(p);
pa.setBackground(Color.lightGray);
pb.setBackground(Color.lightGray);
pc.setBackground(Color.lightGray);
pd.setBackground(Color.lightGray);
pe.setBackground(Color.lightGray);
//
p.add(pa);
p.add(pb);
p.add(pc);
p.add(pd);
p.add(pe);
////-----------------------------------------------------------------------------------------------------------------
-----//
////-------------------------------------images icons-------------------------------------------------------------
--------//
//
pa.setIcon(img1);
pb.setIcon(img2);
pc.setIcon(img3);
pd.setIcon(img4);
pe.setIcon(img5);
m1.addActionListener(new ActionListener() {
@Override
});
mb.add(m1);
m1a.addActionListener(new ActionListener() {
@Override
tA = new JTextField();
tB = new JTextField();
a= Integer.parseInt(b);
if(a>10){
a= Integer.parseInt(b);
P1=200*a;
String S1=Integer.toString(P1);
tA.setText(m1a.getText());
tB.setText(S1);
});
m1b.addActionListener(new ActionListener() {
@Override
tA = new JTextField();
tB = new JTextField();
a= Integer.parseInt(b);
if(a>10){
a= Integer.parseInt(b);
tA.setText(m1b.getText());
JOptionPane.showMessageDialog(null, "Press 'ADD to CART' Button to add your
item to the cart ");
P2=100*a;
String S1=Integer.toString(P2);
tB.setText(S1);
});
m1c.addActionListener(new ActionListener() {
@Override
tA = new JTextField();
tB = new JTextField();
a= Integer.parseInt(b);
if(a>10){
a= Integer.parseInt(b);
tA.setText(m1c.getText());
String S1=Integer.toString(P3);
tB.setText(S1);
});
m1.add(m1a);
m1.add(m1b);
m1.add(m1c);
mb2.add(m2);
m2a.addActionListener(new ActionListener() {
@Override
tA = new JTextField();
tB = new JTextField();
a= Integer.parseInt(b);
if(a>10){
JOptionPane.showMessageDialog(null," Limit exceeded");
a= Integer.parseInt(b);
tA.setText(m2a.getText());
P4=400*a;
String S1=Integer.toString(P4);
tB.setText(S1);
});
m2b.addActionListener(new ActionListener() {
@Override
tA = new JTextField();
tB = new JTextField();
a= Integer.parseInt(b);
if(a>10){
tA.setText(m2b.getText());
P5=600*a;
String S1=Integer.toString(P5);
tB.setText(S1);
});
m2c.addActionListener(new ActionListener() {
@Override
tA = new JTextField();
tB = new JTextField();
a= Integer.parseInt(b);
if(a>10){
a= Integer.parseInt(b);
}
tA.setText(m2c.getText());
P6=500*a;
String S1=Integer.toString(P6);
tB.setText(S1);
});
m2.add(m2a);
m2.add(m2b);
m2.add(m2c);
mb3.add(m3);
m3a.addActionListener(new ActionListener() {
@Override
tA = new JTextField();
tB = new JTextField();
b=JOptionPane.showInputDialog(" Enter quantity (limit 10)","1");
a= Integer.parseInt(b);
if(a>10){
a= Integer.parseInt(b);
tA.setText(m3a.getText());
P7=250*a;
String S1=Integer.toString(P7);
tB.setText(S1);
});
m3b.addActionListener(new ActionListener() {
@Override
tA = new JTextField();
tB = new JTextField();
a= Integer.parseInt(b);
if(a>10){
a= Integer.parseInt(b);
tA.setText(m3b.getText());
P8=180*a;
String S1=Integer.toString(P8);
tB.setText(S1);
});
m3c.addActionListener(new ActionListener() {
@Override
tA = new JTextField();
tB = new JTextField();
a= Integer.parseInt(b);
if(a>10){
a= Integer.parseInt(b);
tA.setText(m3c.getText());
P9=260*a;
String S1=Integer.toString(P9);
tB.setText(S1);
});
m3.add(m3a);
m3.add(m3b);
m3.add(m3c);
//
mb4.add(m4);
@Override
tA = new JTextField();
tB = new JTextField();
a= Integer.parseInt(b);
if(a>10){
a= Integer.parseInt(b);
tA.setText(m4a.getText());
P10=250*a;
String S1=Integer.toString(P10);
tB.setText(S1);
});
m4b.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
tA = new JTextField();
tB = new JTextField();
a= Integer.parseInt(b);
if(a>10){
a= Integer.parseInt(b);
tA.setText(m4b.getText());
P11=230*a;
String S1=Integer.toString(P11);
tB.setText(S1);
});
m4c.addActionListener(new ActionListener() {
@Override
tA = new JTextField();
tB = new JTextField();
a= Integer.parseInt(b);
if(a>10){
a= Integer.parseInt(b);
tA.setText(m4c.getText());
P12=260*a;
String S1=Integer.toString(P12);
tB.setText(S1);
});
m4.add(m4a);
m4.add(m4b);
m4.add(m4c);
JMenuBar mb5=new JMenuBar();
mb5.add(m5);
m5a.addActionListener(new ActionListener() {
@Override
tA = new JTextField();
tB = new JTextField();
a= Integer.parseInt(b);
if(a>10){
a= Integer.parseInt(b);
tA.setText(m5a.getText());
P13=400*a;
String S1=Integer.toString(P13);
tB.setText(S1);
});
m5b.addActionListener(new ActionListener() {
@Override
tA = new JTextField();
tB = new JTextField();
a= Integer.parseInt(b);
if(a>10){
a= Integer.parseInt(b);
tA.setText(m5b.getText());
P14 = 230*a;
String S1=Integer.toString(P14);
tB.setText(S1);
});
m5c.addActionListener(new ActionListener() {
@Override
tA = new JTextField();
tB = new JTextField();
a= Integer.parseInt(b);
if(a>10){
a= Integer.parseInt(b);
tA.setText(m5c.getText());
P15 = 250*a;
String S1=Integer.toString(P15);
tB.setText(S1);
}
});
m5.add(m5a);
m5.add(m5b);
m5.add(m5c);
p.add(mb);
p.add(mb2);
p.add(mb3);
p.add(mb4);
p.add(mb5);
//---------------------------------------------------------------------------------------------------------------//
f2.add(add);
add.setFocusable(false);
add.setBorder(BorderFactory.createLineBorder(Color.black));
add.setBackground(Color.white);
add.addActionListener(new ActionListener() {
@Override
String stg[]={tA.getText(),b,tB.getText()};
dt=(DefaultTableModel)tab1.getModel();
dt.addRow(stg);
});
nxt = new JButton("Next");
nxt.setSize(100, 30);
f2.add(nxt);
nxt.setFocusable(false);
nxt.setBorder(BorderFactory.createLineBorder(Color.black));
nxt.setBackground(Color.white);
//--------------------------------------------3rd Panel----------------------------------------------------------//
nxt.addActionListener(new ActionListener() {
@Override
if(e.getSource().equals(nxt)){
f2.setVisible(false);
Code Screenshot:
Frame 3:
Code:
f3.setSize(1366, 768);
f3.setLayout(new GridLayout(1,2));
f3.setVisible(true);
p4.setBackground(Color.lightGray);
p4.setLayout(new FlowLayout());
p4.setIcon(p4img);
lA.setFont(new Font("Arial",Font.BOLD,25));
lA.setBackground(Color.red);
done.setPreferredSize(new Dimension(340,20));
done.setBackground(Color.PINK.brighter());
done.setBorder(BorderFactory.createLineBorder(Color.white));
done.addActionListener(new ActionListener() {
@Override
if(ta.getText().equals("")&&tb.getText().equals("")&&tc.getText().equals("")){
else{
});
p4.add(lA);
p4.add(la);
p4.add(ta);
p4.add(lb);
p4.add(tb);
p4.add(lc);
p4.add(tc);
p4.add(ld);
p4.add(done);
//Label for cart
p5.setBackground(Color.gray);
p5.setLayout(new BorderLayout());
p5.setIcon(p5img);
l6.setFont(new Font("Arial",Font.BOLD,25));
l6.setBackground(Color.red);
l7.setBackground(Color.blue);
l8.setBackground(Color.yellow);
l9.setBackground(Color.cyan);
l9.setLayout(new FlowLayout());
NetP=P1+P2+P3+P4+P5+P6+P7+P8+P9+P10+P11+P12+P13+P14+P15;
l9.add(L_l9);
// l9.add(T_l9);
l6a.setBounds(80,20,70,90);
l6a.setFont(new Font("Arial",Font.BOLD,25));
p5.add(tab1, BorderLayout.CENTER);
p5.add(l6, BorderLayout.NORTH);
p5.add(l7, BorderLayout.WEST);
p5.add(l8, BorderLayout.EAST);
p5.add(l9, BorderLayout.SOUTH);
l6.add(l6a);
f3.add(p5);
f3.add(p4);
f3.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
});
}
Code Screenshot: