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