Java

Touchable shop Pos system using Java

The Touchable Shop POS (Point of Sale) system is a sophisticated software solution developed using Java. Designed specifically for fruit shops, this system efficiently manages sales and transactions, ensuring smooth and streamlined operations. With its user-friendly interface and robust functionality, the Touchable Shop POS system is an essential tool for modern fruit retailers.

Lets Do Step by Step Touchable shop Pos

The system shall be able to select the relevant Fruit types.

Step 1: implement  MouseListener 

public class Bill extends javax.swing.JFrame  implements MouseListener

Step 2:  set the addMouseListener(this) in to each label.  write it inside the constructor.

public class Bill extends javax.swing.JFrame  implements MouseListener {
    public Bill() {
        initComponents();
         lblBanana.addMouseListener(this);
         lblPoires.addMouseListener(this);
         lblApple.addMouseListener(this);
         lblPineapple.addMouseListener(this);
         lblPomme.addMouseListener(this);
         lblMango.addMouseListener(this);
    }

after implemented the MouseListener it ask to implement all the abstract method of MouseListener.you must implement it.write code inside the mouseClicked event.

public void mouseClicked(MouseEvent e) {
        
        if(e.getSource() == lblBanana){
        qty = Double.parseDouble(JOptionPane.showInputDialog("Enter Qty"));
        
        df = (DefaultTableModel)tblTable.getModel();
          name = "Banana";
          price = 2.40;
         
        System.out.printf("%.2f%n", tot = qty * price);
        
        df.addRow(new Object []{
           
            name,
            price,
            qty,
            tot
        
        });
        Double sum = 0.0;
        for(int i=0; i < tblTable.getRowCount(); i++)
        {
          sum = sum + Double.parseDouble(tblTable.getValueAt(i, 3).toString());
        }
        System.out.printf("%.2f%n", sum);
        items = tblTable.getRowCount();
        System.out.println(sum);
        System.out.println(items);
        txtTot.setText(Double.toString(sum));
        lblItems.setText(Integer.toString(items));
        
                
       
       }
       else if (e.getSource() == lblPoires)
       {
          qty = Double.parseDouble(JOptionPane.showInputDialog("Enter Qty"));
           df = (DefaultTableModel)tblTable.getModel();
          name = "Poires";
          price = 3.0;
         
        tot = qty * price;
        
        df.addRow(new Object []{
           
            name,
            price,
            qty,
            tot
        
        });
        Double sum = 0.0;
        for(int i=0; i < tblTable.getRowCount(); i++)
        {
          sum = sum + Double.parseDouble(tblTable.getValueAt(i, 3).toString());
        }
        System.out.println((int) Math.round(sum));
        items = tblTable.getRowCount();
        System.out.println(sum);
        System.out.println(items);
        txtTot.setText(Double.toString(sum));
        lblItems.setText(Integer.toString(items));
       }
       
       else if (e.getSource() == lblApple)
       {
          qty = Double.parseDouble(JOptionPane.showInputDialog("Enter Qty"));
           df = (DefaultTableModel)tblTable.getModel();
          name = "Apple";
          price = 1.0;
         
        tot = qty * price;
        
        df.addRow(new Object []{
           
            name,
            price,
            qty,
            tot
        
        });
        Double sum = 0.0;
        for(int i=0; i < tblTable.getRowCount(); i++)
        {
          sum = sum + Double.parseDouble(tblTable.getValueAt(i, 3).toString());
        }
        System.out.println((int) Math.round(sum));
        items = tblTable.getRowCount();
        System.out.println(sum);
        System.out.println(items);
        txtTot.setText(Double.toString(sum));
        lblItems.setText(Integer.toString(items));
       }
       else if (e.getSource() == lblPineapple)
       {
          qty = Double.parseDouble(JOptionPane.showInputDialog("Enter Qty"));
           df = (DefaultTableModel)tblTable.getModel();
          name = "PineApple";
          price = 3.0;
         
        tot = qty * price;
        
        df.addRow(new Object []{
           
            name,
            price,
            qty,
            tot
        
        });
        Double sum = 0.0;
        for(int i=0; i < tblTable.getRowCount(); i++)
        {
          sum = sum + Double.parseDouble(tblTable.getValueAt(i, 3).toString());
        }
        System.out.println((int) Math.round(sum));
        items = tblTable.getRowCount();
        System.out.println(sum);
        System.out.println(items);
        txtTot.setText(Double.toString(sum));
        lblItems.setText(Integer.toString(items));
       }
       else if (e.getSource() == lblApple)
       {
          qty = Double.parseDouble(JOptionPane.showInputDialog("Enter Qty"));
           df = (DefaultTableModel)tblTable.getModel();
          name = "Apple";
          price = 1.0;
         
        tot = qty * price;
        
        df.addRow(new Object []{
           
            name,
            price,
            qty,
            tot
        
        });
        Double sum = 0.0;
        for(int i=0; i < tblTable.getRowCount(); i++)
        {
          sum = sum + Double.parseDouble(tblTable.getValueAt(i, 3).toString());
        }
        System.out.println((int) Math.round(sum));
        items = tblTable.getRowCount();
        System.out.println(sum);
        System.out.println(items);
        txtTot.setText(Double.toString(sum));
        lblItems.setText(Integer.toString(items));
       }
       else if (e.getSource() == lblPomme)
       {
         qty = Double.parseDouble(JOptionPane.showInputDialog("Enter Qty"));
           df = (DefaultTableModel)tblTable.getModel();
          name = "Pogrante";
          price = 1.0;
         
        tot = qty * price;
        
        df.addRow(new Object []{
           
            name,
            price,
            qty,
            tot
        
        });
        Double sum = 0.0;
        for(int i=0; i < tblTable.getRowCount(); i++)
        {
          sum = sum + Double.parseDouble(tblTable.getValueAt(i, 3).toString());
        }
        System.out.println((int) Math.round(sum));
        items = tblTable.getRowCount();
        System.out.println(sum);
        System.out.println(items);
        txtTot.setText(Double.toString(sum));
        lblItems.setText(Integer.toString(items));
       }
       else{
          qty = Double.parseDouble(JOptionPane.showInputDialog("Enter Qty"));
           df = (DefaultTableModel)tblTable.getModel();
          name = "Mango";
          price = 1.0;
         
        tot = qty * price;
        
        df.addRow(new Object []{
           
            name,
            price,
            qty,
            tot
        
        });
        Double sum = 0.0;
        for(int i=0; i < tblTable.getRowCount(); i++)
        {
          sum = sum + Double.parseDouble(tblTable.getValueAt(i, 3).toString());
        }
        System.out.println((int) Math.round(sum));
        items = tblTable.getRowCount();
        System.out.println(sum);
        System.out.println(items);
        txtTot.setText(Double.toString(sum));
        lblItems.setText(Integer.toString(items)); 
        } 
    }

Calculate the Balance

public void cal()
   {
     double tottal = Double.parseDouble(txtTot.getText());
     double pay = Double.parseDouble(txtPaid.getText());
     double bal;
     
    
     if(tottal < pay)
     {
       bal = pay - tottal;
       txtBalance.setText(Double.toString(bal));
     }
     else
     {
         JOptionPane.showMessageDialog(null, "Not Valied Money  ");
    }
   }

Design the Bill

public void bill()
    {
       
    System.out.println("Bill button clicked"); 
    System.setProperty("file.encoding", "UTF-8");

    String total = txtTot.getText();
    String pay = txtPaid.getText();
    String bal = txtBalance.getText();

    DefaultTableModel model = (DefaultTableModel) tblTable.getModel();

    // Set the font size
    txtbill.setFont(new Font("Arial Black", Font.PLAIN, 10)); 
    txtbill.setText(txtbill.getText() + "       ___________________________________________________\n");
    txtbill.setText(txtbill.getText() + "                                          DeviJames                                      \n");
    txtbill.setText(txtbill.getText() + "                                     Welcome to our shop                                     \n");
    txtbill.setText(txtbill.getText() + "       ___________________________________________________\n");

    // Heading
    txtbill.setText(txtbill.getText() + " Product\tPrice\tQty\tAmount\n");
    for (int i = 0; i < model.getRowCount(); i++) {
        String pname = (String) model.getValueAt(i, 0);
        String price = model.getValueAt(i, 1).toString(); 
        String qty = model.getValueAt(i, 2).toString(); 
        String amount = model.getValueAt(i, 3).toString(); 

        txtbill.setText(txtbill.getText() + "  " + pname + "\t" + price + "\t" + qty + "\t" + amount + "\n");
    }

    txtbill.setText(txtbill.getText() + "\n");
    txtbill.setText(txtbill.getText() + "\t" + "\t" + "     Subtotal :  " + total + "\n");
    txtbill.setText(txtbill.getText() + "\t" + "\t" + "     Pay          :  " + pay + "\n");
    txtbill.setText(txtbill.getText() + "\t" + "\t" + "   _______________ "+ "\n");
    txtbill.setText(txtbill.getText() + "\t" + "\t" + "     Balance  :  " + bal + "\n");
    txtbill.setText(txtbill.getText() + "\n");
    txtbill.setText(txtbill.getText() + "       ___________________________________________________\n");
    txtbill.setText(txtbill.getText() + "                             THANK YOU COME AGAIN              \n");
}

Paste the code inside the Calculate Button

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
      String tot = txtTot.getText();

      if(tot.isEmpty())
      {
          JOptionPane.showMessageDialog(null, "Total is Empty ");
      }
      else{
          cal();

      }

  }                                        

Paste the code inside the Print Button

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // Print Bill

        String pay = txtPaid.getText();
        String bal = txtBalance.getText();

        if(pay.isEmpty() && bal.isEmpty())
        {
            JOptionPane.showMessageDialog(this, "Paid and Balance is empty ");
            txtPaid.requestFocus();
        }
        else{
            try {
                bill();
                txtbill.print();

            } catch (PrinterException ex) {
                
            }
        }

    }

Paste the code inside the Finish Button

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    df.setRowCount(0);
       txtTot.setText("");
       txtPaid.setText("");
       txtBalance.setText("");
       txtbill.setText("");
       lblItems.setText(""); 
   }

i have attached the video link below. which will do this tutorials step by step.

 

admin

Recent Posts

ChatGPT Free Online Download the ChatGPT App Easily

Have you ever wanted to talk to a friendly, smart robot that helps you with…

4 days ago

Free GPT Chat? DeepSeek AI Does It Better

DeepSeek AI is becoming a friendly and powerful new tool in the world of artificial…

2 weeks ago

Spring Boot MySQL Complete CRUD REST API [ Free Sourecode ]

Do you want to become an expert in Spring Boot CRUD operations? This comprehensive tutorial…

2 weeks ago

CREATE Responsive Navigation Bar with FlexBox CSS!

Modern websites must have a navigation bar that is clear and responsive. FlexBox CSS is…

4 weeks ago

Registration with image upload Java Jdbc(Download Source code)

Introduction In this section, we will guide you step by step in the development of an image upload registration system in Java using MySQL and JDBC. In the application, users register…

2 months ago

Build Your First Responsive Login Form Using HTML and CSS FlexBox

Creating a responsive login form is a crucial skill for any web developer. In this…

3 months ago