SHARE
TWEET

ItemUI

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