document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1.  
  2. /**
  3.  * Write a description of class Main here.
  4.  *
  5.  * @author (your name)
  6.  * @version (a version number or a date)
  7.  */
  8. import javax.swing.JOptionPane;//kelas jendela dialog: input, error, dll
  9. import javax.swing.table.DefaultTableModel;//membuat tabel
  10.  
  11. /*
  12.  * To change this license header, choose License Headers in Project Properties.
  13.  * To change this template file, choose Tools | Templates
  14.  * and open the template in the editor.
  15.  */
  16.  
  17. public class ItemUI extends javax.swing.JFrame {
  18.  
  19.     public ItemList theList = new ItemList();
  20.     public ItemList soldList = new ItemList();
  21.     public double totalSale = 0;
  22.  
  23.     /**
  24.      * Creates new form Item
  25.      */
  26.     public ItemUI() {
  27.  
  28.         initComponents();
  29.         panel1.setVisible(false);
  30.         panel2.setVisible(true);
  31.         panel3.setVisible(false);
  32.         panel4.setVisible(false);
  33.     }
  34.  
  35.     /**
  36.      * This method is called from within the constructor to initialize the form.
  37.      * WARNING: Do NOT modify this code. The content of this method is always
  38.      * regenerated by the Form Editor.
  39.      */
  40.     @SuppressWarnings("unchecked")
  41.     // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  42.     private void initComponents() {
  43.  
  44.         panel1 = new javax.swing.JPanel();//panel addstock
  45.         nameLabel = new javax.swing.JLabel();
  46.         ItemNumberLabel = new javax.swing.JLabel();
  47.         qtyLabel = new javax.swing.JLabel();
  48.         priceLabel = new javax.swing.JLabel();
  49.         priceField = new javax.swing.JTextField();
  50.         qtyField = new javax.swing.JTextField();
  51.         numberField = new javax.swing.JTextField();
  52.         nameField = new javax.swing.JTextField();
  53.         newButton = new javax.swing.JButton();
  54.         saveButton = new javax.swing.JButton();
  55.         backButton = new javax.swing.JButton();
  56.         exitButton = new javax.swing.JButton();
  57.         panel2 = new javax.swing.JPanel();//panel purchase
  58.         purchaseButton1 = new javax.swing.JButton();
  59.         stockButton = new javax.swing.JButton();
  60.         totalSaleButton = new javax.swing.JButton();
  61.         showBillLabel = new javax.swing.JLabel();
  62.         jButton1 = new javax.swing.JButton();
  63.         ItemButton = new javax.swing.JButton();
  64.         jButton2 = new javax.swing.JButton();
  65.         shopNameLabel = new javax.swing.JLabel();
  66.         jButton4 = new javax.swing.JButton();
  67.         jButton5 = new javax.swing.JButton();
  68.         panel3 = new javax.swing.JPanel();//panel total sale
  69.         hmButton = new javax.swing.JButton();
  70.         jScrollPane2 = new javax.swing.JScrollPane();
  71.         dataTable = new javax.swing.JTable();
  72.         panel4 = new javax.swing.JPanel();
  73.         jLabel2 = new javax.swing.JLabel();
  74.         purchaseLabel1 = new javax.swing.JLabel();
  75.         item1Label1 = new javax.swing.JLabel();
  76.         qtLabel1 = new javax.swing.JLabel();
  77.         pLabel1 = new javax.swing.JLabel();
  78.         subtotalLabel1 = new javax.swing.JLabel();
  79.         subtotal1Label1 = new javax.swing.JLabel();
  80.         p1Label1 = new javax.swing.JLabel();
  81.         qt1Label1 = new javax.swing.JLabel();
  82.         item2Label1 = new javax.swing.JLabel();
  83.         qt2Label2 = new javax.swing.JLabel();
  84.         qt3Label2 = new javax.swing.JLabel();
  85.         item3Label1 = new javax.swing.JLabel();
  86.         qt3Label3 = new javax.swing.JLabel();
  87.         qt2Label3 = new javax.swing.JLabel();
  88.         subtotal2Label1 = new javax.swing.JLabel();
  89.         subtotal3Label1 = new javax.swing.JLabel();
  90.         qt4Label2 = new javax.swing.JLabel();
  91.         subtotal4Label1 = new javax.swing.JLabel();
  92.         subtotal5Label1 = new javax.swing.JLabel();
  93.         subtotal6Label1 = new javax.swing.JLabel();
  94.         jSeparator2 = new javax.swing.JSeparator();
  95.         billLabel1 = new javax.swing.JLabel();
  96.         totalBillLabel1 = new javax.swing.JLabel();
  97.         qt6Label2 = new javax.swing.JLabel();
  98.         qt5Label2 = new javax.swing.JLabel();
  99.         qt4Label3 = new javax.swing.JLabel();
  100.         qt5Label3 = new javax.swing.JLabel();
  101.         qt6Label3 = new javax.swing.JLabel();
  102.         item6Label1 = new javax.swing.JLabel();
  103.         item5Label1 = new javax.swing.JLabel();
  104.         item4Label1 = new javax.swing.JLabel();
  105.  
  106.         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  107.         setTitle("My Shop Point of Sale");
  108.         setResizable(false);
  109.  
  110.         panel1.setFocusable(false);
  111.         panel1.setMaximumSize(new java.awt.Dimension(360, 260));
  112.         panel1.setRequestFocusEnabled(false);
  113.  
  114.         nameLabel.setText("Name:");//purchase
  115.  
  116.         ItemNumberLabel.setText("Item Number:");
  117.  
  118.         qtyLabel.setText("Quantity:");
  119.  
  120.         priceLabel.setText("Price:");
  121.  
  122.         priceField.addActionListener(new java.awt.event.ActionListener() {
  123.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  124.                 priceFieldActionPerformed(evt);
  125.             }
  126.         });
  127.         priceField.addKeyListener(new java.awt.event.KeyAdapter() {
  128.             public void keyTyped(java.awt.event.KeyEvent evt) {
  129.                 priceFieldKeyTyped(evt);
  130.             }
  131.         });
  132.  
  133.         qtyField.addActionListener(new java.awt.event.ActionListener() {
  134.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  135.                 qtyFieldActionPerformed(evt);
  136.             }
  137.         });
  138.         qtyField.addKeyListener(new java.awt.event.KeyAdapter() {
  139.             public void keyTyped(java.awt.event.KeyEvent evt) {
  140.                 qtyFieldKeyTyped(evt);
  141.             }
  142.         });
  143.  
  144.         numberField.addFocusListener(new java.awt.event.FocusAdapter() {
  145.             public void focusLost(java.awt.event.FocusEvent evt) {
  146.                 numberFieldFocusLost(evt);
  147.             }
  148.         });
  149.         numberField.addActionListener(new java.awt.event.ActionListener() {
  150.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  151.                 numberFieldActionPerformed(evt);
  152.             }
  153.         });
  154.         numberField.addKeyListener(new java.awt.event.KeyAdapter() {
  155.             public void keyTyped(java.awt.event.KeyEvent evt) {
  156.                 numberFieldKeyTyped(evt);
  157.             }
  158.         });
  159.  
  160.         nameField.addActionListener(new java.awt.event.ActionListener() {
  161.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  162.                 nameFieldActionPerformed(evt);
  163.             }
  164.         });
  165.         nameField.addKeyListener(new java.awt.event.KeyAdapter() {
  166.             public void keyTyped(java.awt.event.KeyEvent evt) {
  167.                 nameFieldKeyTyped(evt);
  168.             }
  169.         });
  170.  
  171.         newButton.setText("New");
  172.         newButton.addActionListener(new java.awt.event.ActionListener() {
  173.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  174.                 newButtonActionPerformed(evt);
  175.             }
  176.         });
  177.  
  178.         saveButton.setText("Save");
  179.         saveButton.addActionListener(new java.awt.event.ActionListener() {
  180.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  181.                 saveButtonActionPerformed(evt);
  182.             }
  183.         });
  184.  
  185.         backButton.setText("Back");
  186.         backButton.addActionListener(new java.awt.event.ActionListener() {
  187.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  188.                 backButtonActionPerformed(evt);
  189.             }
  190.         });
  191.  
  192.         exitButton.setText("Exit");
  193.         exitButton.addActionListener(new java.awt.event.ActionListener() {
  194.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  195.                 exitButtonActionPerformed(evt);
  196.             }
  197.         });
  198.  
  199.         javax.swing.GroupLayout panel1Layout = new javax.swing.GroupLayout(panel1);
  200.         panel1.setLayout(panel1Layout);
  201.         panel1Layout.setHorizontalGroup(
  202.             panel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  203.             .addGroup(panel1Layout.createSequentialGroup()
  204.                 .addGroup(panel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  205.                     .addGroup(panel1Layout.createSequentialGroup()
  206.                         .addContainerGap()
  207.                         .addGroup(panel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  208.                             .addComponent(nameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
  209.                             .addComponent(ItemNumberLabel)
  210.                             .addComponent(qtyLabel)
  211.                             .addComponent(priceLabel))
  212.                         .addGap(69, 69, 69)
  213.                         .addGroup(panel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  214.                             .addComponent(priceField, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
  215.                             .addComponent(qtyField, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
  216.                             .addComponent(numberField, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
  217.                             .addComponent(nameField, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)))
  218.                     .addGroup(panel1Layout.createSequentialGroup()
  219.                         .addGap(23, 23, 23)
  220.                         .addComponent(newButton)
  221.                         .addGap(18, 18, 18)
  222.                         .addComponent(saveButton)
  223.                         .addGap(18, 18, 18)
  224.                         .addComponent(backButton)
  225.                         .addGap(18, 18, 18)
  226.                         .addComponent(exitButton, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)))
  227.                 .addContainerGap(72, Short.MAX_VALUE))
  228.         );
  229.         panel1Layout.setVerticalGroup(
  230.             panel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  231.             .addGroup(panel1Layout.createSequentialGroup()
  232.                 .addContainerGap()
  233.                 .addGroup(panel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  234.                     .addComponent(nameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
  235.                     .addComponent(nameField, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
  236.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  237.                 .addGroup(panel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  238.                     .addComponent(ItemNumberLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
  239.                     .addComponent(numberField, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
  240.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  241.                 .addGroup(panel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  242.                     .addComponent(qtyLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
  243.                     .addComponent(qtyField, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
  244.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  245.                 .addGroup(panel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  246.                     .addComponent(priceLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
  247.                     .addComponent(priceField, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
  248.                 .addGap(18, 18, 18)
  249.                 .addGroup(panel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  250.                     .addComponent(saveButton)
  251.                     .addComponent(backButton)
  252.                     .addComponent(newButton)
  253.                     .addComponent(exitButton))
  254.                 .addContainerGap(268, Short.MAX_VALUE))
  255.         );
  256.  
  257.         panel2.setFocusable(false);
  258.         panel2.setRequestFocusEnabled(false);
  259.  
  260.         purchaseButton1.setText("Purchase");
  261.         purchaseButton1.setFocusPainted(false);
  262.         purchaseButton1.setFocusable(false);
  263.         purchaseButton1.addActionListener(new java.awt.event.ActionListener() {
  264.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  265.                 purchaseButton1ActionPerformed(evt);
  266.             }
  267.         });
  268.  
  269.         stockButton.setText("Add Stock");
  270.         stockButton.addActionListener(new java.awt.event.ActionListener() {
  271.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  272.                 stockButtonActionPerformed(evt);
  273.             }
  274.         });
  275.  
  276.         totalSaleButton.setText("Total Sale");
  277.         totalSaleButton.addActionListener(new java.awt.event.ActionListener() {
  278.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  279.                 totalSaleButtonActionPerformed(evt);
  280.             }
  281.         });
  282.  
  283.         jButton1.setText("Delete Item");
  284.         jButton1.addActionListener(new java.awt.event.ActionListener() {
  285.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  286.                 jButton1ActionPerformed(evt);
  287.             }
  288.         });
  289.  
  290.         ItemButton.setText("Add Item");
  291.         ItemButton.addActionListener(new java.awt.event.ActionListener() {
  292.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  293.                 ItemButtonActionPerformed(evt);
  294.             }
  295.         });
  296.  
  297.         jButton2.setText("Show Items");
  298.         jButton2.addActionListener(new java.awt.event.ActionListener() {
  299.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  300.                 jButton2ActionPerformed(evt);
  301.             }
  302.         });
  303.  
  304.         shopNameLabel.setText("                           Casio Cash Register");
  305.  
  306.         jButton4.setText("Sold Items");
  307.         jButton4.addActionListener(new java.awt.event.ActionListener() {
  308.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  309.                 jButton4ActionPerformed(evt);
  310.             }
  311.         });
  312.  
  313.         jButton5.setText("Exit");
  314.         jButton5.addActionListener(new java.awt.event.ActionListener() {
  315.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  316.                 jButton5ActionPerformed(evt);
  317.             }
  318.         });
  319.  
  320.         javax.swing.GroupLayout panel2Layout = new javax.swing.GroupLayout(panel2);
  321.         panel2.setLayout(panel2Layout);
  322.         panel2Layout.setHorizontalGroup(
  323.             panel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  324.             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panel2Layout.createSequentialGroup()
  325.                 .addContainerGap(25, Short.MAX_VALUE)
  326.                 .addComponent(shopNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 356, javax.swing.GroupLayout.PREFERRED_SIZE)
  327.                 .addGap(25, 25, 25))
  328.             .addGroup(panel2Layout.createSequentialGroup()
  329.                 .addGap(37, 37, 37)
  330.                 .addGroup(panel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  331.                     .addGroup(panel2Layout.createSequentialGroup()
  332.                         .addGroup(panel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  333.                             .addGroup(panel2Layout.createSequentialGroup()
  334.                                 .addComponent(stockButton)
  335.                                 .addGap(18, 18, 18)
  336.                                 .addComponent(purchaseButton1))
  337.                             .addComponent(showBillLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 141, javax.swing.GroupLayout.PREFERRED_SIZE))
  338.                         .addGap(18, 18, 18)
  339.                         .addComponent(totalSaleButton))
  340.                     .addGroup(panel2Layout.createSequentialGroup()
  341.                         .addGroup(panel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  342.                             .addGroup(panel2Layout.createSequentialGroup()
  343.                                 .addComponent(ItemButton)
  344.                                 .addGap(18, 18, 18)
  345.                                 .addComponent(jButton1))
  346.                             .addComponent(jButton4))
  347.                         .addGap(18, 18, 18)
  348.                         .addGroup(panel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  349.                             .addComponent(jButton2)
  350.                             .addComponent(jButton5))))
  351.                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  352.         );
  353.  
  354.         panel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {ItemButton, jButton1, jButton2, purchaseButton1, stockButton, totalSaleButton});
  355.  
  356.         panel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jButton4, jButton5});
  357.  
  358.         panel2Layout.setVerticalGroup(
  359.             panel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  360.             .addGroup(panel2Layout.createSequentialGroup()
  361.                 .addContainerGap()
  362.                 .addComponent(shopNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
  363.                 .addGap(31, 31, 31)
  364.                 .addGroup(panel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  365.                     .addComponent(stockButton)
  366.                     .addComponent(purchaseButton1)
  367.                     .addComponent(totalSaleButton))
  368.                 .addGap(18, 18, 18)
  369.                 .addComponent(showBillLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
  370.                 .addGap(26, 26, 26)
  371.                 .addGroup(panel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  372.                     .addComponent(jButton2)
  373.                     .addComponent(jButton1)
  374.                     .addComponent(ItemButton))
  375.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 58, Short.MAX_VALUE)
  376.                 .addGroup(panel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  377.                     .addComponent(jButton4)
  378.                     .addComponent(jButton5))
  379.                 .addGap(26, 26, 26))
  380.         );
  381.  
  382.         panel2Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {ItemButton, jButton1, jButton2, purchaseButton1, stockButton, totalSaleButton});
  383.  
  384.         hmButton.setText("Home Page");
  385.         hmButton.addActionListener(new java.awt.event.ActionListener() {
  386.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  387.                 hmButtonActionPerformed(evt);
  388.             }
  389.         });
  390.  
  391.         dataTable.setModel(new javax.swing.table.DefaultTableModel(
  392.             new Object [][] {
  393.                 {null, null, null, null},
  394.                 {null, null, null, null},
  395.                 {null, null, null, null},
  396.                 {null, null, null, null}
  397.             },
  398.             new String [] {
  399.                 "Item Number", "Item Name", "Quantity", "Price"
  400.             }
  401.         ) {
  402.             Class[] types = new Class [] {
  403.                 java.lang.Integer.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class
  404.             };
  405.  
  406.             public Class getColumnClass(int columnIndex) {
  407.                 return types [columnIndex];
  408.             }
  409.         });
  410.         jScrollPane2.setViewportView(dataTable);
  411.  
  412.         javax.swing.GroupLayout panel3Layout = new javax.swing.GroupLayout(panel3);
  413.         panel3.setLayout(panel3Layout);
  414.         panel3Layout.setHorizontalGroup(
  415.             panel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  416.             .addGroup(panel3Layout.createSequentialGroup()
  417.                 .addContainerGap()
  418.                 .addComponent(hmButton)
  419.                 .addContainerGap(219, Short.MAX_VALUE))
  420.             .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
  421.         );
  422.         panel3Layout.setVerticalGroup(
  423.             panel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  424.             .addGroup(panel3Layout.createSequentialGroup()
  425.                 .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 403, javax.swing.GroupLayout.PREFERRED_SIZE)
  426.                 .addGap(13, 13, 13)
  427.                 .addComponent(hmButton)
  428.                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  429.         );
  430.  
  431.         jLabel2.setText("                                                    Receipt");
  432.         jLabel2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
  433.  
  434.         purchaseLabel1.setText("Items Purchased");
  435.  
  436.         item1Label1.setText("it1");
  437.  
  438.         qtLabel1.setText("Quantity");
  439.  
  440.         pLabel1.setText("Price");
  441.  
  442.         subtotalLabel1.setText("Sub Total");
  443.  
  444.         subtotal1Label1.setText("it1");
  445.  
  446.         p1Label1.setText("it1");
  447.  
  448.         qt1Label1.setText("it1");
  449.  
  450.         item2Label1.setText("it2");
  451.  
  452.         qt2Label2.setText("it2");
  453.  
  454.         qt3Label2.setText("it3");
  455.  
  456.         item3Label1.setText("it3");
  457.  
  458.         qt3Label3.setText("it3");
  459.  
  460.         qt2Label3.setText("it2");
  461.  
  462.         subtotal2Label1.setText("it2");
  463.  
  464.         subtotal3Label1.setText("it3");
  465.  
  466.         qt4Label2.setText("it4");
  467.  
  468.         subtotal4Label1.setText("it4");
  469.  
  470.         subtotal5Label1.setText("it5");
  471.  
  472.         subtotal6Label1.setText("it6");
  473.  
  474.         billLabel1.setText("Total Bill:");
  475.  
  476.         totalBillLabel1.setText("tb");
  477.  
  478.         qt6Label2.setText("it6");
  479.  
  480.         qt5Label2.setText("it5");
  481.  
  482.         qt4Label3.setText("it4");
  483.  
  484.         qt5Label3.setText("it5");
  485.  
  486.         qt6Label3.setText("it6");
  487.  
  488.         item6Label1.setText("it6");
  489.  
  490.         item5Label1.setText("it5");
  491.  
  492.         item4Label1.setText("it4");
  493.  
  494.         javax.swing.GroupLayout panel4Layout = new javax.swing.GroupLayout(panel4);
  495.         panel4.setLayout(panel4Layout);
  496.         panel4Layout.setHorizontalGroup(
  497.             panel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  498.             .addGroup(panel4Layout.createSequentialGroup()
  499.                 .addGap(35, 35, 35)
  500.                 .addGroup(panel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  501.                     .addComponent(item2Label1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  502.                     .addComponent(purchaseLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 101, Short.MAX_VALUE)
  503.                     .addComponent(item1Label1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  504.                     .addComponent(item3Label1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  505.                     .addComponent(item4Label1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  506.                     .addComponent(item5Label1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  507.                     .addComponent(item6Label1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  508.                 .addGap(18, 18, 18)
  509.                 .addGroup(panel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  510.                     .addComponent(qtLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
  511.                     .addComponent(qt5Label3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  512.                     .addComponent(qt4Label3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  513.                     .addComponent(qt3Label2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  514.                     .addComponent(qt2Label2, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
  515.                     .addComponent(qt6Label3, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
  516.                     .addComponent(qt1Label1, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE))
  517.                 .addGap(18, 18, 18)
  518.                 .addGroup(panel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  519.                     .addComponent(pLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 65, Short.MAX_VALUE)
  520.                     .addComponent(p1Label1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  521.                     .addComponent(qt2Label3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  522.                     .addComponent(qt3Label3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  523.                     .addComponent(qt4Label2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  524.                     .addComponent(qt5Label2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  525.                     .addComponent(qt6Label2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  526.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  527.                 .addGroup(panel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  528.                     .addGroup(panel4Layout.createSequentialGroup()
  529.                         .addGroup(panel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  530.                             .addComponent(subtotal3Label1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  531.                             .addComponent(subtotal4Label1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  532.                             .addComponent(subtotal5Label1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  533.                             .addComponent(subtotal2Label1, javax.swing.GroupLayout.DEFAULT_SIZE, 65, Short.MAX_VALUE)
  534.                             .addComponent(subtotal6Label1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  535.                         .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  536.                     .addGroup(panel4Layout.createSequentialGroup()
  537.                         .addGroup(panel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  538.                             .addComponent(subtotal1Label1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  539.                             .addComponent(subtotalLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 68, Short.MAX_VALUE))
  540.                         .addGap(21, 21, 21))))
  541.             .addGroup(panel4Layout.createSequentialGroup()
  542.                 .addContainerGap()
  543.                 .addGroup(panel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  544.                     .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  545.                     .addComponent(jSeparator2))
  546.                 .addContainerGap())
  547.             .addGroup(panel4Layout.createSequentialGroup()
  548.                 .addGap(168, 168, 168)
  549.                 .addComponent(billLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
  550.                 .addGap(18, 18, 18)
  551.                 .addComponent(totalBillLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)
  552.                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  553.         );
  554.         panel4Layout.setVerticalGroup(
  555.             panel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  556.             .addGroup(panel4Layout.createSequentialGroup()
  557.                 .addContainerGap()
  558.                 .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
  559.                 .addGap(18, 18, 18)
  560.                 .addGroup(panel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  561.                     .addComponent(purchaseLabel1)
  562.                     .addComponent(qtLabel1)
  563.                     .addComponent(pLabel1)
  564.                     .addComponent(subtotalLabel1))
  565.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  566.                 .addGroup(panel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  567.                     .addGroup(panel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  568.                         .addGroup(panel4Layout.createSequentialGroup()
  569.                             .addComponent(item1Label1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
  570.                             .addGap(18, 18, 18)
  571.                             .addComponent(item2Label1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
  572.                             .addGap(18, 18, 18)
  573.                             .addComponent(item3Label1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
  574.                             .addGap(18, 18, 18)
  575.                             .addComponent(item4Label1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
  576.                             .addGap(18, 18, 18)
  577.                             .addComponent(item5Label1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
  578.                             .addGap(18, 18, 18)
  579.                             .addComponent(item6Label1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
  580.                         .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panel4Layout.createSequentialGroup()
  581.                             .addComponent(qt1Label1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
  582.                             .addGap(18, 18, 18)
  583.                             .addComponent(qt2Label2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
  584.                             .addGap(18, 18, 18)
  585.                             .addComponent(qt3Label2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
  586.                             .addGap(18, 18, 18)
  587.                             .addComponent(qt4Label3, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
  588.                             .addGap(18, 18, 18)
  589.                             .addComponent(qt5Label3, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
  590.                             .addGap(18, 18, 18)
  591.                             .addComponent(qt6Label3, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)))
  592.                     .addGroup(panel4Layout.createSequentialGroup()
  593.                         .addComponent(p1Label1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
  594.                         .addGap(18, 18, 18)
  595.                         .addComponent(qt2Label3, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
  596.                         .addGap(18, 18, 18)
  597.                         .addComponent(qt3Label3, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
  598.                         .addGap(18, 18, 18)
  599.                         .addComponent(qt4Label2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
  600.                         .addGap(18, 18, 18)
  601.                         .addComponent(qt5Label2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
  602.                         .addGap(18, 18, 18)
  603.                         .addComponent(qt6Label2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
  604.                     .addGroup(panel4Layout.createSequentialGroup()
  605.                         .addComponent(subtotal1Label1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
  606.                         .addGap(18, 18, 18)
  607.                         .addComponent(subtotal2Label1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
  608.                         .addGap(18, 18, 18)
  609.                         .addComponent(subtotal3Label1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
  610.                         .addGap(18, 18, 18)
  611.                         .addComponent(subtotal4Label1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
  612.                         .addGap(18, 18, 18)
  613.                         .addComponent(subtotal5Label1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
  614.                         .addGap(18, 18, 18)
  615.                         .addComponent(subtotal6Label1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)))
  616.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  617.                 .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
  618.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  619.                 .addGroup(panel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  620.                     .addComponent(billLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
  621.                     .addGroup(panel4Layout.createSequentialGroup()
  622.                         .addComponent(totalBillLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  623.                         .addGap(5, 5, 5)))
  624.                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  625.         );
  626.  
  627.         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  628.         getContentPane().setLayout(layout);
  629.         layout.setHorizontalGroup(
  630.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  631.             .addComponent(panel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  632.             .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  633.                 .addGroup(layout.createSequentialGroup()
  634.                     .addGap(0, 0, Short.MAX_VALUE)
  635.                     .addComponent(panel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  636.                     .addGap(0, 0, Short.MAX_VALUE)))
  637.             .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  638.                 .addGroup(layout.createSequentialGroup()
  639.                     .addGap(0, 0, Short.MAX_VALUE)
  640.                     .addComponent(panel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  641.                     .addGap(0, 0, Short.MAX_VALUE)))
  642.             .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  643.                 .addGroup(layout.createSequentialGroup()
  644.                     .addGap(0, 0, Short.MAX_VALUE)
  645.                     .addComponent(panel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  646.                     .addGap(0, 0, Short.MAX_VALUE)))
  647.         );
  648.         layout.setVerticalGroup(
  649.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  650.             .addComponent(panel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  651.             .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  652.                 .addGroup(layout.createSequentialGroup()
  653.                     .addGap(0, 0, Short.MAX_VALUE)
  654.                     .addComponent(panel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  655.                     .addGap(0, 0, Short.MAX_VALUE)))
  656.             .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  657.                 .addGroup(layout.createSequentialGroup()
  658.                     .addGap(0, 0, Short.MAX_VALUE)
  659.                     .addComponent(panel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  660.                     .addGap(0, 0, Short.MAX_VALUE)))
  661.             .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  662.                 .addGroup(layout.createSequentialGroup()
  663.                     .addGap(0, 0, Short.MAX_VALUE)
  664.                     .addComponent(panel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  665.                     .addGap(0, 0, Short.MAX_VALUE)))
  666.         );
  667.  
  668.         pack();
  669.     }// </editor-fold>//GEN-END:initComponents
  670.  
  671.     private void priceFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_priceFieldActionPerformed
  672.  
  673.     }//GEN-LAST:event_priceFieldActionPerformed
  674.  
  675.     private void qtyFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_qtyFieldActionPerformed
  676.  
  677.     }//GEN-LAST:event_qtyFieldActionPerformed
  678.  
  679.     private void numberFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_numberFieldActionPerformed
  680.  
  681.     }//GEN-LAST:event_numberFieldActionPerformed
  682.  
  683.     private void nameFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nameFieldActionPerformed
  684.  
  685.     }//GEN-LAST:event_nameFieldActionPerformed
  686.  
  687.     public void reset() {
  688.         nameField.setText("");
  689.         numberField.setText("");
  690.         qtyField.setText("");
  691.         priceField.setText("");
  692.         nameField.requestFocus();
  693.     }
  694.     private void newButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newButtonActionPerformed
  695.         reset();
  696.     }//GEN-LAST:event_newButtonActionPerformed
  697.  
  698.  
  699.     private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveButtonActionPerformed
  700.         String name;
  701.         int itemNumber;
  702.         int qty;
  703.         double price;
  704.         name = nameField.getText();
  705.         itemNumber = Integer.parseInt(numberField.getText());
  706.         qty = Integer.parseInt(qtyField.getText());
  707.         price = Double.parseDouble(priceField.getText());
  708.  
  709.         Item current = theList.first;
  710.         while (current != null) {
  711.             if (itemNumber == current.itemNumber) {
  712.                 JOptionPane.showMessageDialog(this, "This Item Number Already Exist in the List.");
  713.                 return;
  714.             }
  715.             break;
  716.         }
  717.  
  718.         if (price < 0) {
  719.             JOptionPane.showMessageDialog(null, "Price can not be in negative.");
  720.             return;
  721.         } else if (qty < 0) {
  722.             JOptionPane.showMessageDialog(null, "Quantity can not be in negative.");
  723.             return;
  724.         } else {
  725.             theList.insertFirst(name, itemNumber, qty, price);
  726.             JOptionPane.showMessageDialog(null, "Item saved");
  727.         }
  728.  
  729.         reset();
  730.     }//GEN-LAST:event_saveButtonActionPerformed
  731.  
  732.     private void backButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backButtonActionPerformed
  733.         panel1.setVisible(false);
  734.         panel2.setVisible(true);
  735.         panel3.setVisible(false);
  736.         panel4.setVisible(false);
  737.     }//GEN-LAST:event_backButtonActionPerformed
  738.  
  739.     private void exitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitButtonActionPerformed
  740.         System.exit(0);
  741.     }//GEN-LAST:event_exitButtonActionPerformed
  742.  
  743.     private void numberFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_numberFieldFocusLost
  744.         // TODO add your handling code here:
  745.  
  746.     }//GEN-LAST:event_numberFieldFocusLost
  747.     //double totalBill = 0;
  748.     private void purchaseButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_purchaseButton1ActionPerformed
  749.        
  750.         int itNum, qty;
  751.         double total = 0;
  752.         panel1.hide();
  753.         panel3.hide();
  754.         panel2.setVisible(true);
  755.         try {
  756.             String input = JOptionPane.showInputDialog("Enter Item Number:");
  757.             itNum = Integer.parseInt(input);
  758.             String input1 = JOptionPane.showInputDialog("Enter Quantity:");
  759.             qty = Integer.parseInt(input1);
  760.  
  761.             if (theList.isEmpty()) {
  762.                 JOptionPane.showMessageDialog(null, "Sorry! Item list is empty.");
  763.                 return;
  764.             }
  765.             int a = JOptionPane.showConfirmDialog(null, "Want to purchase more items?");
  766.  
  767.             if (a == JOptionPane.YES_OPTION) {
  768.                 this.purchaseButton1ActionPerformed(evt);
  769.                
  770.                
  771.             } else if (a == JOptionPane.CANCEL_OPTION) {
  772.                 return;
  773.             }
  774.            
  775.  
  776.             if (qty > theList.find(itNum).qty) {
  777.                 JOptionPane.showMessageDialog(null, "Sorry! Item is out of Stock");
  778.                 return;
  779.             } else if (itNum != theList.find(itNum).itemNumber) {
  780.                 JOptionPane.showMessageDialog(this, "Sorry! Item is not in the List.");
  781.                 return;
  782.             } else {
  783.                 theList.find(itNum).qty -= qty;
  784.                 total += theList.find(itNum).price * qty;
  785.                 totalSale += total;
  786.                 //totalBill+=total;
  787.             }
  788.             showBillLabel.setText("Total Bill is: " + total);
  789.             if(a != 2){
  790.                 soldList.insertFirst(theList.find(itNum).name, itNum, qty, theList.find(itNum).price*qty);
  791.             }
  792.            
  793.         } catch (Exception ex) {
  794.             JOptionPane.showMessageDialog(this, "Sorry! Item is not in the List.");
  795.         }
  796.     }//GEN-LAST:event_purchaseButton1ActionPerformed
  797.  
  798.     private void stockButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stockButtonActionPerformed
  799.         // TODO add your handling code here:
  800.         int itNum, qty;
  801.  
  802.         try {
  803.             String input = JOptionPane.showInputDialog("Enter Item Number:");
  804.             itNum = Integer.parseInt(input);
  805.             String input1 = JOptionPane.showInputDialog("Enter Quantity:");
  806.             qty = Integer.parseInt(input1);
  807.             if (theList.isEmpty()) {
  808.                 JOptionPane.showMessageDialog(this, "Item List is empty.!");
  809.             } else {
  810.                 theList.find(itNum).qty += qty;
  811.                 JOptionPane.showMessageDialog(this, "Stock Added!");
  812.             }
  813.         } catch (Exception ex) {
  814.             JOptionPane.showMessageDialog(this, ex);
  815.         }
  816.     }//GEN-LAST:event_stockButtonActionPerformed
  817.  
  818.     private void totalSaleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_totalSaleButtonActionPerformed
  819.         // TODO add your handling code here:
  820.         showBillLabel.setText("Total Sale is: " + totalSale);
  821.     }//GEN-LAST:event_totalSaleButtonActionPerformed
  822.  
  823.     private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
  824.         // TODO add your handling code here:
  825.         int itNum;
  826.         try {
  827.             String input = JOptionPane.showInputDialog("Enter Item Number:");
  828.             itNum = Integer.parseInt(input);
  829.             if (theList.isEmpty()) {
  830.                 JOptionPane.showMessageDialog(this, "List is empty!");
  831.             } else {
  832.                 int it = theList.find(itNum).itemNumber;
  833.                 if (it == itNum) {
  834.                     theList.delete(it);
  835.                     JOptionPane.showMessageDialog(this, "Item Deleted!");
  836.                 } else {
  837.                     JOptionPane.showMessageDialog(this, "Invalid Item Number!");
  838.                 }
  839.             }
  840.         } catch (Exception ex) {
  841.             JOptionPane.showMessageDialog(this, "Invalid Item Number!");
  842.         }
  843.     }//GEN-LAST:event_jButton1ActionPerformed
  844.  
  845.     private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
  846.         if (theList.isEmpty()) {
  847.             JOptionPane.showMessageDialog(this, "Item List is empty.!");
  848.         } else {
  849.             panel1.setVisible(false);
  850.             panel2.setVisible(false);
  851.             panel3.setVisible(true);
  852.             panel4.setVisible(false);
  853.  
  854.             Item current = theList.first;
  855.             DefaultTableModel model = (DefaultTableModel) dataTable.getModel();
  856.             model.setRowCount(0);
  857.             while (current != null) {
  858.                 model.addRow(new Object[]{current.itemNumber, current.name, current.qty, current.price});
  859.                 current = current.next;
  860.             }
  861.  
  862.         }
  863.     }//GEN-LAST:event_jButton2ActionPerformed
  864.  
  865.     private void ItemButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ItemButtonActionPerformed
  866.         // TODO add your handling code here:
  867.         panel4.setVisible(false);
  868.         panel3.setVisible(false);
  869.         panel2.setVisible(false);
  870.         panel1.setVisible(true);
  871.     }//GEN-LAST:event_ItemButtonActionPerformed
  872.  
  873.     private void hmButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_hmButtonActionPerformed
  874.         // TODO add your handling code here:
  875.         panel3.hide();
  876.         panel2.setVisible(true);
  877.         panel4.setVisible(false);
  878.         panel1.setVisible(false);
  879.  
  880.     }//GEN-LAST:event_hmButtonActionPerformed
  881.  
  882.     private void nameFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_nameFieldKeyTyped
  883.         // TODO add your handling code here:
  884.         char input = evt.getKeyChar();
  885.         if (!(input < \'0\' || input > \'9\') && input != \'\\b\') {
  886.             evt.consume();
  887.             JOptionPane.showMessageDialog(this, "Name does not contain any numbers!");
  888.         }
  889.     }//GEN-LAST:event_nameFieldKeyTyped
  890.  
  891.     private void numberFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_numberFieldKeyTyped
  892.         // TODO add your handling code here:
  893.         char input = evt.getKeyChar();
  894.         if ((input < \'0\' || input > \'9\') && input != \'\\b\') {
  895.             evt.consume();
  896.             JOptionPane.showMessageDialog(this, "Please enter digits!");
  897.         }
  898.     }//GEN-LAST:event_numberFieldKeyTyped
  899.  
  900.     private void qtyFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_qtyFieldKeyTyped
  901.         // TODO add your handling code here:
  902.         char input = evt.getKeyChar();
  903.         if ((input < \'0\' || input > \'9\') && input != \'\\b\') {
  904.             evt.consume();
  905.             JOptionPane.showMessageDialog(this, "Please enter digits!");
  906.         }
  907.     }//GEN-LAST:event_qtyFieldKeyTyped
  908.  
  909.     private void priceFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_priceFieldKeyTyped
  910.         // TODO add your handling code here:
  911.         char input = evt.getKeyChar();
  912.         if ((input < \'0\' || input > \'9\') && (input != \'\\b\' && input != \'.\')) {
  913.             evt.consume();
  914.             JOptionPane.showMessageDialog(this, "Please enter digits!");
  915.         }
  916.     }//GEN-LAST:event_priceFieldKeyTyped
  917.  
  918.     private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
  919.         // TODO add your handling code here:
  920.         if (soldList.isEmpty()) {
  921.             JOptionPane.showMessageDialog(this, "Item List is empty.!");
  922.         } else {
  923.             panel1.setVisible(false);
  924.             panel2.setVisible(false);
  925.             panel3.setVisible(true);
  926.             panel4.setVisible(false);
  927.  
  928.             Item current = soldList.first;
  929.             DefaultTableModel model = (DefaultTableModel) dataTable.getModel();
  930.             model.setRowCount(0);
  931.             while (current != null) {
  932.                 model.addRow(new Object[]{current.itemNumber, current.name, current.qty, current.price});
  933.                 current = current.next;
  934.             }
  935.  
  936.         }
  937.     }//GEN-LAST:event_jButton4ActionPerformed
  938.  
  939.     private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
  940.         // TODO add your handling code here:
  941.         System.exit(0);
  942.     }//GEN-LAST:event_jButton5ActionPerformed
  943.  
  944.     /**
  945.      * @param args the command line arguments
  946.      */
  947.     public static void main(String args[]) {
  948.         /* Set the Nimbus look and feel */
  949.         //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  950.         /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  951.          * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  952.          */
  953.         try {
  954.             for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  955.                 if ("Nimbus".equals(info.getName())) {
  956.                     javax.swing.UIManager.setLookAndFeel(info.getClassName());
  957.                     break;
  958.                 }
  959.             }
  960.         } catch (ClassNotFoundException ex) {
  961.             java.util.logging.Logger.getLogger(ItemUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  962.         } catch (InstantiationException ex) {
  963.             java.util.logging.Logger.getLogger(ItemUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  964.         } catch (IllegalAccessException ex) {
  965.             java.util.logging.Logger.getLogger(ItemUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  966.         } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  967.             java.util.logging.Logger.getLogger(ItemUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  968.         }
  969.         //</editor-fold>
  970.         //</editor-fold>
  971.  
  972.         /* Create and display the form */
  973.         java.awt.EventQueue.invokeLater(new Runnable() {
  974.             public void run() {
  975.                 new ItemUI().setVisible(true);
  976.                 new ItemUI().panel2.setVisible(false);
  977.                 new ItemUI().panel3.setVisible(false);
  978.                 new ItemUI().panel4.setVisible(false);
  979.  
  980.             }
  981.         });
  982.     }
  983.  
  984.     // Variables declaration - do not modify//GEN-BEGIN:variables
  985.     private javax.swing.JButton ItemButton;
  986.     private javax.swing.JLabel ItemNumberLabel;
  987.     public javax.swing.JButton backButton;
  988.     private javax.swing.JLabel billLabel1;
  989.     public javax.swing.JTable dataTable;
  990.     public javax.swing.JButton exitButton;
  991.     private javax.swing.JButton hmButton;
  992.     private javax.swing.JLabel item1Label1;
  993.     private javax.swing.JLabel item2Label1;
  994.     private javax.swing.JLabel item3Label1;
  995.     private javax.swing.JLabel item4Label1;
  996.     private javax.swing.JLabel item5Label1;
  997.     private javax.swing.JLabel item6Label1;
  998.     private javax.swing.JButton jButton1;
  999.     private javax.swing.JButton jButton2;
  1000.     private javax.swing.JButton jButton4;
  1001.     private javax.swing.JButton jButton5;
  1002.     private javax.swing.JLabel jLabel2;
  1003.     private javax.swing.JScrollPane jScrollPane2;
  1004.     private javax.swing.JSeparator jSeparator2;
  1005.     public javax.swing.JTextField nameField;
  1006.     private javax.swing.JLabel nameLabel;
  1007.     public javax.swing.JButton newButton;
  1008.     public javax.swing.JTextField numberField;
  1009.     private javax.swing.JLabel p1Label1;
  1010.     private javax.swing.JLabel pLabel1;
  1011.     private javax.swing.JPanel panel1;
  1012.     private javax.swing.JPanel panel2;
  1013.     private javax.swing.JPanel panel3;
  1014.     private javax.swing.JPanel panel4;
  1015.     public javax.swing.JTextField priceField;
  1016.     private javax.swing.JLabel priceLabel;
  1017.     private javax.swing.JButton purchaseButton1;
  1018.     private javax.swing.JLabel purchaseLabel1;
  1019.     private javax.swing.JLabel qt1Label1;
  1020.     private javax.swing.JLabel qt2Label2;
  1021.     private javax.swing.JLabel qt2Label3;
  1022.     private javax.swing.JLabel qt3Label2;
  1023.     private javax.swing.JLabel qt3Label3;
  1024.     private javax.swing.JLabel qt4Label2;
  1025.     private javax.swing.JLabel qt4Label3;
  1026.     private javax.swing.JLabel qt5Label2;
  1027.     private javax.swing.JLabel qt5Label3;
  1028.     private javax.swing.JLabel qt6Label2;
  1029.     private javax.swing.JLabel qt6Label3;
  1030.     private javax.swing.JLabel qtLabel1;
  1031.     public javax.swing.JTextField qtyField;
  1032.     private javax.swing.JLabel qtyLabel;
  1033.     public javax.swing.JButton saveButton;
  1034.     private javax.swing.JLabel shopNameLabel;
  1035.     private javax.swing.JLabel showBillLabel;
  1036.     private javax.swing.JButton stockButton;
  1037.     private javax.swing.JLabel subtotal1Label1;
  1038.     private javax.swing.JLabel subtotal2Label1;
  1039.     private javax.swing.JLabel subtotal3Label1;
  1040.     private javax.swing.JLabel subtotal4Label1;
  1041.     private javax.swing.JLabel subtotal5Label1;
  1042.     private javax.swing.JLabel subtotal6Label1;
  1043.     private javax.swing.JLabel subtotalLabel1;
  1044.     private javax.swing.JLabel totalBillLabel1;
  1045.     private javax.swing.JButton totalSaleButton;
  1046.     // End of variables declaration//GEN-END:variables
  1047. }
');