/Users/johnr/Desktop/IA pdf Downloads/Criteria__P__-_Coding_Project_Upload_all_2022-05-03/Final CS IA_Agraj/AgrajIA/src/agrajia/MainGUI.java
   1 /*
   2  * To change this license header, choose License Headers in Project Properties.
   3  * To change this template file, choose Tools | Templates
   4  * and open the template in the editor.
   5  */
   6 package agrajia;
   7 
   8 import java.sql.Connection;
   9 import java.sql.DriverManager;
  10 import java.sql.ResultSet;
  11 import java.sql.SQLException;
  12 import java.sql.Statement;
  13 import java.util.logging.Level;
  14 import java.util.logging.Logger;
  15 import javax.swing.table.DefaultTableModel;
  16 import java.awt.Component;
  17 import java.awt.Image;
  18 import java.io.BufferedInputStream;
  19 import java.io.BufferedOutputStream;
  20 import java.io.File;
  21 import java.io.FileInputStream;
  22 import java.io.FileNotFoundException;
  23 import java.io.FileOutputStream;
  24 import java.io.IOException;
  25 import static javax.management.Query.gt;
  26 import javax.swing.ImageIcon;
  27 import javax.swing.JFileChooser;
  28 import javax.swing.JFrame;
  29 import javax.swing.JLabel;
  30 import javax.swing.JComboBox;
  31 import javax.swing.JOptionPane;
  32 import javax.swing.JTable;
  33 import javax.swing.filechooser.FileNameExtensionFilter;
  34 import javax.swing.table.DefaultTableModel;
  35 import javax.swing.table.TableCellRenderer;
  36 import javax.swing.table.TableColumn;
  37 import java.awt.event.*;
  38 import java.awt.*;
  39 import java.util.Arrays;
  40 import javax.swing.*;
  41 import java.net.*;
  42 import java.util.Scanner;
  43 
  44 
  45 /**
  46  *
  47  * @author 17248
  48  */
  49 public class MainGUI extends javax.swing.JFrame {
  50 
  51     /**
  52      * Creates new form MainGUI
  53      */
  54     public MainGUI() {
  55         initComponents();
  56     }
  57 
  58     /**
  59      * This method is called from within the constructor to initialize the form.
  60      * WARNING: Do NOT modify this code. The content of this method is always
  61      * regenerated by the Form Editor.
  62      */
  63     @SuppressWarnings("unchecked")
  64     // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
  65     private void initComponents() {
  66 
  67         jTabbedPane1 = new javax.swing.JTabbedPane();
  68         jPanel1 = new javax.swing.JPanel();
  69         jScrollPane1 = new javax.swing.JScrollPane();
  70         OrderList = new javax.swing.JTable();
  71         refreshButton = new javax.swing.JButton();
  72         jButton1 = new javax.swing.JButton();
  73         jPanel2 = new javax.swing.JPanel();
  74         RecipeLabel = new javax.swing.JLabel();
  75         jTabbedPane2 = new javax.swing.JTabbedPane();
  76         jPanel6 = new javax.swing.JPanel();
  77         jLabel1 = new javax.swing.JLabel();
  78         jScrollPane2 = new javax.swing.JScrollPane();
  79         jTextArea1 = new javax.swing.JTextArea();
  80         jPanel7 = new javax.swing.JPanel();
  81         jLabel2 = new javax.swing.JLabel();
  82         jScrollPane3 = new javax.swing.JScrollPane();
  83         jTextArea2 = new javax.swing.JTextArea();
  84         jPanel8 = new javax.swing.JPanel();
  85         jLabel3 = new javax.swing.JLabel();
  86         jScrollPane4 = new javax.swing.JScrollPane();
  87         jTextArea3 = new javax.swing.JTextArea();
  88         jPanel9 = new javax.swing.JPanel();
  89         jLabel4 = new javax.swing.JLabel();
  90         jScrollPane5 = new javax.swing.JScrollPane();
  91         jTextArea4 = new javax.swing.JTextArea();
  92         jPanel10 = new javax.swing.JPanel();
  93         jLabel5 = new javax.swing.JLabel();
  94         jScrollPane6 = new javax.swing.JScrollPane();
  95         jTextArea5 = new javax.swing.JTextArea();
  96         jPanel3 = new javax.swing.JPanel();
  97         jScrollPane7 = new javax.swing.JScrollPane();
  98         inventoryTable = new javax.swing.JTable();
  99         refreshInventory = new javax.swing.JButton();
 100         quantityUpdater = new javax.swing.JButton();
 101         jLabel7 = new javax.swing.JLabel();
 102         jLabel8 = new javax.swing.JLabel();
 103         jLabel9 = new javax.swing.JLabel();
 104         jLabel10 = new javax.swing.JLabel();
 105         jLabel11 = new javax.swing.JLabel();
 106         jLabel12 = new javax.swing.JLabel();
 107         jLabel13 = new javax.swing.JLabel();
 108         jLabel14 = new javax.swing.JLabel();
 109         quantityUpdater1 = new javax.swing.JButton();
 110         quantityUpdater2 = new javax.swing.JButton();
 111         quantityUpdater3 = new javax.swing.JButton();
 112         quantityUpdater4 = new javax.swing.JButton();
 113         quantityUpdater5 = new javax.swing.JButton();
 114         quantityUpdater6 = new javax.swing.JButton();
 115         quantityUpdater7 = new javax.swing.JButton();
 116 
 117         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
 118 
 119         jTabbedPane1.addMouseListener(new java.awt.event.MouseAdapter() {
 120             public void mouseClicked(java.awt.event.MouseEvent evt) {
 121                 jTabbedPane1MouseClicked(evt);
 122             }
 123         });
 124 
 125         OrderList.setModel(new javax.swing.table.DefaultTableModel(
 126             new Object [][] {
 127 
 128             },
 129             new String [] {
 130                 "Customer Name", "Phone Number", "Email", "Order Date", "Shipping Date", "Comments", "Items"
 131             }
 132         ));
 133         OrderList.setGridColor(new java.awt.Color(0, 0, 0));
 134         jScrollPane1.setViewportView(OrderList);
 135 
 136         refreshButton.setText("Refresh Rows");
 137         refreshButton.addMouseListener(new java.awt.event.MouseAdapter() {
 138             public void mouseReleased(java.awt.event.MouseEvent evt) {
 139                 refreshButtonMouseReleased(evt);
 140             }
 141         });
 142 
 143         jButton1.setText("Remove Row");
 144         jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
 145             public void mouseReleased(java.awt.event.MouseEvent evt) {
 146                 jButton1MouseReleased(evt);
 147             }
 148         });
 149 
 150         javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
 151         jPanel1.setLayout(jPanel1Layout);
 152         jPanel1Layout.setHorizontalGroup(
 153             jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 154             .addGroup(jPanel1Layout.createSequentialGroup()
 155                 .addGap(46, 46, 46)
 156                 .addComponent(refreshButton)
 157                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
 158                 .addComponent(jButton1)
 159                 .addGap(123, 123, 123))
 160             .addGroup(jPanel1Layout.createSequentialGroup()
 161                 .addContainerGap()
 162                 .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 754, javax.swing.GroupLayout.PREFERRED_SIZE)
 163                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
 164         );
 165         jPanel1Layout.setVerticalGroup(
 166             jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 167             .addGroup(jPanel1Layout.createSequentialGroup()
 168                 .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 488, javax.swing.GroupLayout.PREFERRED_SIZE)
 169                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
 170                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 171                     .addComponent(refreshButton)
 172                     .addComponent(jButton1))
 173                 .addGap(0, 1436, Short.MAX_VALUE))
 174         );
 175 
 176         jTabbedPane1.addTab("Order List", jPanel1);
 177 
 178         RecipeLabel.setFont(new java.awt.Font("Lucida Grande", 1, 14)); // NOI18N
 179         RecipeLabel.setText("Select Item From Booklet:");
 180 
 181         jLabel1.setText("Choco Brownie");
 182 
 183         jTextArea1.setColumns(20);
 184         jTextArea1.setRows(5);
 185         jTextArea1.setText("Ingredients:\nFlour - 100g\nSugar - 100g\nButter - 100g\nChoco Powder - 50g\nEggs - 2\n");
 186         jScrollPane2.setViewportView(jTextArea1);
 187 
 188         javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
 189         jPanel6.setLayout(jPanel6Layout);
 190         jPanel6Layout.setHorizontalGroup(
 191             jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 192             .addGroup(jPanel6Layout.createSequentialGroup()
 193                 .addContainerGap()
 194                 .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 195                     .addGroup(jPanel6Layout.createSequentialGroup()
 196                         .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)
 197                         .addGap(0, 0, Short.MAX_VALUE))
 198                     .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 721, Short.MAX_VALUE))
 199                 .addContainerGap())
 200         );
 201         jPanel6Layout.setVerticalGroup(
 202             jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 203             .addGroup(jPanel6Layout.createSequentialGroup()
 204                 .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
 205                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 206                 .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 311, javax.swing.GroupLayout.PREFERRED_SIZE)
 207                 .addGap(0, 118, Short.MAX_VALUE))
 208         );
 209 
 210         jTabbedPane2.addTab("Choco Brownie", jPanel6);
 211 
 212         jLabel2.setText("Pound Cake");
 213 
 214         jTextArea2.setColumns(20);
 215         jTextArea2.setRows(5);
 216         jTextArea2.setText("Ingredients:\nFlour - 100g\nSugar - 100g\nButter - 100g\nEggs - 2\n\n");
 217         jScrollPane3.setViewportView(jTextArea2);
 218 
 219         javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
 220         jPanel7.setLayout(jPanel7Layout);
 221         jPanel7Layout.setHorizontalGroup(
 222             jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 223             .addGroup(jPanel7Layout.createSequentialGroup()
 224                 .addContainerGap()
 225                 .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 226                     .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 721, Short.MAX_VALUE)
 227                     .addGroup(jPanel7Layout.createSequentialGroup()
 228                         .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)
 229                         .addGap(0, 0, Short.MAX_VALUE)))
 230                 .addContainerGap())
 231         );
 232         jPanel7Layout.setVerticalGroup(
 233             jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 234             .addGroup(jPanel7Layout.createSequentialGroup()
 235                 .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
 236                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 237                 .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 311, javax.swing.GroupLayout.PREFERRED_SIZE)
 238                 .addContainerGap(118, Short.MAX_VALUE))
 239         );
 240 
 241         jTabbedPane2.addTab("Pound Cake", jPanel7);
 242 
 243         jLabel3.setText("Madeline Cookie");
 244 
 245         jTextArea3.setColumns(20);
 246         jTextArea3.setRows(5);
 247         jTextArea3.setText("Flour - 100g\nButter -100g\nSugar - 100g\nSalt - 50g\nEggs - 2\n\n");
 248         jScrollPane4.setViewportView(jTextArea3);
 249 
 250         javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
 251         jPanel8.setLayout(jPanel8Layout);
 252         jPanel8Layout.setHorizontalGroup(
 253             jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 254             .addGroup(jPanel8Layout.createSequentialGroup()
 255                 .addContainerGap()
 256                 .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 257                     .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 721, Short.MAX_VALUE)
 258                     .addGroup(jPanel8Layout.createSequentialGroup()
 259                         .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)
 260                         .addGap(0, 0, Short.MAX_VALUE)))
 261                 .addContainerGap())
 262         );
 263         jPanel8Layout.setVerticalGroup(
 264             jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 265             .addGroup(jPanel8Layout.createSequentialGroup()
 266                 .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
 267                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 268                 .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 311, javax.swing.GroupLayout.PREFERRED_SIZE)
 269                 .addContainerGap(118, Short.MAX_VALUE))
 270         );
 271 
 272         jTabbedPane2.addTab("Madeline Cookie", jPanel8);
 273 
 274         jLabel4.setText("Choco Chip Cookie");
 275 
 276         jTextArea4.setColumns(20);
 277         jTextArea4.setRows(5);
 278         jTextArea4.setText("Flour - 100g\nSugar - 100g\nButter - 100g\nEggs - 2\nChoco Chips - 50g\nSalt - 100g\n");
 279         jScrollPane5.setViewportView(jTextArea4);
 280 
 281         javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
 282         jPanel9.setLayout(jPanel9Layout);
 283         jPanel9Layout.setHorizontalGroup(
 284             jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 285             .addGroup(jPanel9Layout.createSequentialGroup()
 286                 .addContainerGap()
 287                 .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 288                     .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 721, Short.MAX_VALUE)
 289                     .addGroup(jPanel9Layout.createSequentialGroup()
 290                         .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE)
 291                         .addGap(0, 0, Short.MAX_VALUE)))
 292                 .addContainerGap())
 293         );
 294         jPanel9Layout.setVerticalGroup(
 295             jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 296             .addGroup(jPanel9Layout.createSequentialGroup()
 297                 .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
 298                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 299                 .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 311, javax.swing.GroupLayout.PREFERRED_SIZE)
 300                 .addContainerGap(118, Short.MAX_VALUE))
 301         );
 302 
 303         jTabbedPane2.addTab("Choco Chip Cookie", jPanel9);
 304 
 305         jLabel5.setText("Choco Lava Cake");
 306 
 307         jTextArea5.setColumns(20);
 308         jTextArea5.setRows(5);
 309         jTextArea5.setText("Flour - 200g\nSugar - 150g\nButter - 120g\nEggs - 3\nChoco Powder - 100g");
 310         jScrollPane6.setViewportView(jTextArea5);
 311 
 312         javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
 313         jPanel10.setLayout(jPanel10Layout);
 314         jPanel10Layout.setHorizontalGroup(
 315             jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 316             .addGroup(jPanel10Layout.createSequentialGroup()
 317                 .addContainerGap()
 318                 .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 319                     .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 721, Short.MAX_VALUE)
 320                     .addGroup(jPanel10Layout.createSequentialGroup()
 321                         .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE)
 322                         .addGap(0, 0, Short.MAX_VALUE)))
 323                 .addContainerGap())
 324         );
 325         jPanel10Layout.setVerticalGroup(
 326             jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 327             .addGroup(jPanel10Layout.createSequentialGroup()
 328                 .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
 329                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 330                 .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 311, javax.swing.GroupLayout.PREFERRED_SIZE)
 331                 .addContainerGap(118, Short.MAX_VALUE))
 332         );
 333 
 334         jTabbedPane2.addTab("Choco Lava Cake", jPanel10);
 335 
 336         javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
 337         jPanel2.setLayout(jPanel2Layout);
 338         jPanel2Layout.setHorizontalGroup(
 339             jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 340             .addGroup(jPanel2Layout.createSequentialGroup()
 341                 .addContainerGap()
 342                 .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 343                     .addGroup(jPanel2Layout.createSequentialGroup()
 344                         .addComponent(RecipeLabel)
 345                         .addGap(0, 0, Short.MAX_VALUE))
 346                     .addComponent(jTabbedPane2, javax.swing.GroupLayout.Alignment.TRAILING))
 347                 .addContainerGap())
 348         );
 349         jPanel2Layout.setVerticalGroup(
 350             jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 351             .addGroup(jPanel2Layout.createSequentialGroup()
 352                 .addComponent(RecipeLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
 353                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
 354                 .addComponent(jTabbedPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 510, javax.swing.GroupLayout.PREFERRED_SIZE)
 355                 .addContainerGap(1427, Short.MAX_VALUE))
 356         );
 357 
 358         jTabbedPane1.addTab("Recipe Booklet", jPanel2);
 359 
 360         inventoryTable.setModel(new javax.swing.table.DefaultTableModel(
 361             new Object [][] {
 362 
 363             },
 364             new String [] {
 365                 "Ingredient Name", "Quantity", "Unit"
 366             }
 367         ) {
 368             boolean[] canEdit = new boolean [] {
 369                 false, true, true
 370             };
 371 
 372             public boolean isCellEditable(int rowIndex, int columnIndex) {
 373                 return canEdit [columnIndex];
 374             }
 375         });
 376         inventoryTable.setGridColor(new java.awt.Color(0, 0, 0));
 377         jScrollPane7.setViewportView(inventoryTable);
 378 
 379         refreshInventory.setText("Refresh Rows");
 380         refreshInventory.addMouseListener(new java.awt.event.MouseAdapter() {
 381             public void mouseReleased(java.awt.event.MouseEvent evt) {
 382                 refreshInventoryMouseReleased(evt);
 383             }
 384         });
 385 
 386         quantityUpdater.setText("Update");
 387         quantityUpdater.addMouseListener(new java.awt.event.MouseAdapter() {
 388             public void mouseReleased(java.awt.event.MouseEvent evt) {
 389                 quantityUpdaterMouseReleased(evt);
 390             }
 391         });
 392 
 393         jLabel7.setText("Sugar");
 394 
 395         jLabel8.setText("Flour");
 396 
 397         jLabel9.setText("Salt");
 398 
 399         jLabel10.setText("Choco Chips");
 400 
 401         jLabel11.setText("Milk");
 402 
 403         jLabel12.setText("Butter");
 404 
 405         jLabel13.setText("Eggs");
 406 
 407         jLabel14.setText("Choco Powder");
 408 
 409         quantityUpdater1.setText("Update");
 410         quantityUpdater1.addMouseListener(new java.awt.event.MouseAdapter() {
 411             public void mouseReleased(java.awt.event.MouseEvent evt) {
 412                 quantityUpdater1MouseReleased(evt);
 413             }
 414         });
 415 
 416         quantityUpdater2.setText("Update");
 417         quantityUpdater2.addMouseListener(new java.awt.event.MouseAdapter() {
 418             public void mouseReleased(java.awt.event.MouseEvent evt) {
 419                 quantityUpdater2MouseReleased(evt);
 420             }
 421         });
 422 
 423         quantityUpdater3.setText("Update");
 424         quantityUpdater3.addMouseListener(new java.awt.event.MouseAdapter() {
 425             public void mouseReleased(java.awt.event.MouseEvent evt) {
 426                 quantityUpdater3MouseReleased(evt);
 427             }
 428         });
 429 
 430         quantityUpdater4.setText("Update");
 431         quantityUpdater4.addMouseListener(new java.awt.event.MouseAdapter() {
 432             public void mouseReleased(java.awt.event.MouseEvent evt) {
 433                 quantityUpdater4MouseReleased(evt);
 434             }
 435         });
 436 
 437         quantityUpdater5.setText("Update");
 438         quantityUpdater5.addMouseListener(new java.awt.event.MouseAdapter() {
 439             public void mouseReleased(java.awt.event.MouseEvent evt) {
 440                 quantityUpdater5MouseReleased(evt);
 441             }
 442         });
 443 
 444         quantityUpdater6.setText("Update");
 445         quantityUpdater6.addMouseListener(new java.awt.event.MouseAdapter() {
 446             public void mouseReleased(java.awt.event.MouseEvent evt) {
 447                 quantityUpdater6MouseReleased(evt);
 448             }
 449         });
 450 
 451         quantityUpdater7.setText("Update");
 452         quantityUpdater7.addMouseListener(new java.awt.event.MouseAdapter() {
 453             public void mouseReleased(java.awt.event.MouseEvent evt) {
 454                 quantityUpdater7MouseReleased(evt);
 455             }
 456         });
 457 
 458         javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
 459         jPanel3.setLayout(jPanel3Layout);
 460         jPanel3Layout.setHorizontalGroup(
 461             jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 462             .addComponent(jScrollPane7, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 766, Short.MAX_VALUE)
 463             .addGroup(jPanel3Layout.createSequentialGroup()
 464                 .addGap(21, 21, 21)
 465                 .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 466                     .addGroup(jPanel3Layout.createSequentialGroup()
 467                         .addComponent(jLabel8)
 468                         .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 469                             .addGroup(jPanel3Layout.createSequentialGroup()
 470                                 .addGap(238, 238, 238)
 471                                 .addComponent(refreshInventory, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE))
 472                             .addGroup(jPanel3Layout.createSequentialGroup()
 473                                 .addGap(69, 69, 69)
 474                                 .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
 475                                     .addComponent(quantityUpdater)
 476                                     .addComponent(quantityUpdater1)))))
 477                     .addComponent(jLabel7)
 478                     .addGroup(jPanel3Layout.createSequentialGroup()
 479                         .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 480                             .addComponent(jLabel10)
 481                             .addComponent(jLabel11)
 482                             .addComponent(jLabel12)
 483                             .addComponent(jLabel13)
 484                             .addComponent(jLabel14)
 485                             .addComponent(jLabel9))
 486                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
 487                         .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 488                             .addComponent(quantityUpdater2)
 489                             .addComponent(quantityUpdater7)
 490                             .addComponent(quantityUpdater6)
 491                             .addComponent(quantityUpdater5)
 492                             .addComponent(quantityUpdater4)
 493                             .addComponent(quantityUpdater3))))
 494                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
 495         );
 496         jPanel3Layout.setVerticalGroup(
 497             jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 498             .addGroup(jPanel3Layout.createSequentialGroup()
 499                 .addGap(100, 100, 100)
 500                 .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
 501                 .addGap(34, 34, 34)
 502                 .addComponent(refreshInventory)
 503                 .addGap(18, 18, 18)
 504                 .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 505                     .addComponent(jLabel7)
 506                     .addComponent(quantityUpdater))
 507                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 508                 .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 509                     .addComponent(jLabel8)
 510                     .addComponent(quantityUpdater1))
 511                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 512                 .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 513                     .addComponent(jLabel9)
 514                     .addComponent(quantityUpdater2))
 515                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 516                 .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 517                     .addComponent(jLabel10)
 518                     .addComponent(quantityUpdater3))
 519                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 520                 .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 521                     .addComponent(jLabel11)
 522                     .addComponent(quantityUpdater4))
 523                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 524                 .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 525                     .addComponent(jLabel12)
 526                     .addComponent(quantityUpdater5))
 527                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 528                 .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 529                     .addComponent(jLabel13)
 530                     .addComponent(quantityUpdater6))
 531                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 532                 .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 533                     .addComponent(jLabel14)
 534                     .addComponent(quantityUpdater7))
 535                 .addContainerGap(1352, Short.MAX_VALUE))
 536         );
 537 
 538         jTabbedPane1.addTab("Inventory", jPanel3);
 539 
 540         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
 541         getContentPane().setLayout(layout);
 542         layout.setHorizontalGroup(
 543             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 544             .addGroup(layout.createSequentialGroup()
 545                 .addGap(46, 46, 46)
 546                 .addComponent(jTabbedPane1)
 547                 .addContainerGap())
 548         );
 549         layout.setVerticalGroup(
 550             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 551             .addGroup(layout.createSequentialGroup()
 552                 .addGap(21, 21, 21)
 553                 .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
 554                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
 555         );
 556 
 557         pack();
 558     }// </editor-fold>                        
 559 
 560 
 561     private void refreshButtonMouseReleased(java.awt.event.MouseEvent evt) {                                            
 562         //refreshes the row to bring the newest orders into the orderList table
 563         Connection myConn = null;
 564         Statement myStmt = null;
 565         ResultSet myRs = null;
 566 
 567         String user = "root";
 568         String pass = "paggu2004";
 569    
 570         try {
 571             // 1. Get a connection to database
 572             myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/orders", user, pass);
 573 
 574             // 2. Create a statement
 575             myStmt = myConn.createStatement();
 576 
 577             // 3. Execute SQL query
 578             myRs = myStmt.executeQuery("select * from orders.orders");
 579 
 580             // 4. Process the result set
 581             DefaultTableModel tableModel = (DefaultTableModel)OrderList.getModel();
 582             tableModel.setRowCount(0);
 583             while (myRs.next()) {
 584                 String customerName = myRs.getString("customer_name");
 585                 String phoneNumber = myRs.getString("phone_number");
 586                 String email = myRs.getString("email");
 587                 String orderDate = myRs.getString("order_date");
 588                 String shippingDate = myRs.getString("shipping_date");
 589                 String comments = myRs.getString("comments");
 590                 String items = myRs.getString("food");
 591                 
 592                 String tableDate[] = {customerName, phoneNumber, email, orderDate, shippingDate, comments, items};
 593                     tableModel.addRow(tableDate);
 594             }
 595             
 596 
 597         } catch (SQLException e) {
 598         } finally {
 599             if (myRs != null) {
 600                 try {
 601                     myRs.close();
 602                 } catch (SQLException ex) {
 603                     Logger.getLogger(MainGUI.class.getName()).log(Level.SEVERE, null, ex);
 604                 }
 605             }
 606 
 607             if (myStmt != null) {
 608                 try {
 609                     myStmt.close();
 610                 } catch (SQLException ex) {
 611                     Logger.getLogger(MainGUI.class.getName()).log(Level.SEVERE, null, ex);
 612                 }
 613             }
 614 
 615             if (myConn != null) {
 616                 try {
 617                     myConn.close();
 618                 } catch (SQLException ex) {
 619                     Logger.getLogger(MainGUI.class.getName()).log(Level.SEVERE, null, ex);
 620                 }
 621             }
 622         }
 623     }                                           
 624 
 625     
 626     private void jButton1MouseReleased(java.awt.event.MouseEvent evt) {                                       
 627         //deleting a row from the orderList table and removing it from the database
 628         //get table model       
 629         DefaultTableModel tableModel = (DefaultTableModel)OrderList.getModel();
 630         //delete selected row
 631         if(OrderList.getSelectedRowCount()==1){
 632             //if single row is selected then delete
 633             String items = OrderList.getValueAt(OrderList.getSelectedRow(), 6).toString();
 634             tableModel.removeRow(OrderList.getSelectedRow());
 635             
 636             Connection myConn = null;
 637             Statement myStmt = null;
 638             ResultSet myRs = null;
 639 
 640             String user = "root";
 641             String pass = "paggu2004";
 642    
 643         try {
 644             // 1. Get a connection to database
 645             myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/orders", user, pass);
 646         } catch (SQLException ex) {
 647             Logger.getLogger(MainGUI.class.getName()).log(Level.SEVERE, null, ex);
 648         }
 649 
 650         try {
 651             // 2. Create a statement
 652             myStmt = myConn.createStatement();
 653         } catch (SQLException ex) {
 654             Logger.getLogger(MainGUI.class.getName()).log(Level.SEVERE, null, ex);
 655         }
 656 
 657         try {
 658             // 3. Execute SQL query
 659             myRs = myStmt.executeQuery("select * from orders.orders");
 660         } catch (SQLException ex) {
 661             Logger.getLogger(MainGUI.class.getName()).log(Level.SEVERE, null, ex);
 662         }
 663         int orderID = 0;
 664         try {
 665             // 4. Process the result set
 666             
 667             while (myRs.next()) {
 668                 try {
 669                     orderID = myRs.getInt("order_id");
 670                 } catch (SQLException ex) {
 671                     Logger.getLogger(MainGUI.class.getName()).log(Level.SEVERE, null, ex);
 672                 }
 673             }       
 674         } catch (SQLException ex) {
 675             Logger.getLogger(MainGUI.class.getName()).log(Level.SEVERE, null, ex);
 676             
 677        }
 678             String order_id = Integer.toString(orderID);
 679             String jdbcUrl = "jdbc:mysql://localhost:3306/orders";
 680             String sql = "delete from orders where order_id="+order_id;
 681 
 682             try (Connection conn = DriverManager.getConnection(jdbcUrl, user, pass); 
 683             Statement stmt = conn.createStatement();) {
 684       
 685             stmt.executeUpdate(sql);
 686             System.out.println("Record deleted successfully");
 687             } 
 688             catch (SQLException ex) {
 689             Logger.getLogger(MainGUI.class.getName()).log(Level.SEVERE, null, ex);
 690             }
 691             String[] tokens = {"Brownie", "PoundCake", "Madeline", "ChocoLava", "ChocoChip"};
 692             //updating the inventory database after finishing an order
 693             //there is a lot of repetition here as each food item as separate ingredients that it uses
 694             if (items.contains(tokens[0])){
 695                 try {
 696                 myStmt.executeQuery("select * from orders.inventory; ");
 697                 } catch (SQLException ex) {
 698                 Logger.getLogger(MainGUI.class.getName()).log(Level.SEVERE, null, ex);
 699                 }
 700                 String sql2 = "update orders.inventory set quantity=quantity-100 where ingredient_name='sugar'; ";
 701                 String sql3 = "update orders.inventory set quantity=quantity-50 where ingredient_name='choco powder'; ";
 702                 String sql4 = "update orders.inventory set quantity=quantity-2 where ingredient_name='eggs'; ";
 703                 String sql5 = "update orders.inventory set quantity=quantity-100 where ingredient_name='flour'; ";
 704                 String sql6 = "update orders.inventory set quantity=quantity-100 where ingredient_name='butter';";
 705                 try {
 706                 Connection conn = DriverManager.getConnection(jdbcUrl, user, pass); 
 707                 Statement stmt = conn.createStatement();
 708       
 709                 stmt.executeUpdate(sql2);
 710                 stmt.executeUpdate(sql3);
 711                 stmt.executeUpdate(sql4);
 712                 stmt.executeUpdate(sql5);
 713                 stmt.executeUpdate(sql6);
 714                 
 715                 System.out.println("Database updated successfully");
 716                 } catch (SQLException ex) {
 717                 Logger.getLogger(MainGUI.class.getName()).log(Level.SEVERE, null, ex);
 718         
 719                 }
 720             }
 721             if (items.contains(tokens[1])){
 722                 String sql2 = "update orders.inventory set quantity=quantity-100 where ingredient_name='flour'; ";
 723                 String sql3 = "update orders.inventory set quantity=quantity-2 where ingredient_name='eggs'; ";
 724                 String sql4 = "update orders.inventory set quantity=quantity-100 where ingredient_name='butter'; ";
 725                 String sql5 = "update orders.inventory set quantity=quantity-100 where ingredient_name='sugar';";
 726                 try (Connection conn = DriverManager.getConnection(jdbcUrl, user, pass); 
 727                 Statement stmt = conn.createStatement();) {
 728       
 729                 stmt.executeUpdate(sql2);
 730                 stmt.executeUpdate(sql3);
 731                 stmt.executeUpdate(sql4);
 732                 stmt.executeUpdate(sql5);
 733                 
 734                 System.out.println("Database updated successfully");
 735                 } catch (SQLException ex) {
 736                 Logger.getLogger(MainGUI.class.getName()).log(Level.SEVERE, null, ex);
 737         
 738                 }
 739             }
 740             
 741             if (items.contains(tokens[2])){
 742                 String sql2 = "update orders.inventory set quantity=quantity-100 where ingredient_name='flour'; ";
 743                 String sql3 = "update orders.inventory set quantity=quantity-2 where ingredient_name='eggs'; ";
 744                 String sql4 = "update orders.inventory set quantity=quantity-100 where ingredient_name='butter'; ";
 745                 String sql5 = "update orders.inventory set quantity=quantity-100 where ingredient_name='sugar';";
 746                 String sql6 = "update orders.inventory set quantity=quantity-50 where ingredient_name='salt';";
 747                 try (Connection conn = DriverManager.getConnection(jdbcUrl, user, pass); 
 748                 Statement stmt = conn.createStatement();) {
 749       
 750                 stmt.executeUpdate(sql2);
 751                 stmt.executeUpdate(sql3);
 752                 stmt.executeUpdate(sql4);
 753                 stmt.executeUpdate(sql5);
 754                 stmt.executeUpdate(sql6);
 755                 
 756                 System.out.println("Database updated successfully");
 757                 } catch (SQLException ex) {
 758                     Logger.getLogger(MainGUI.class.getName()).log(Level.SEVERE, null, ex);
 759                 }
 760             }
 761             if (items.contains(tokens[3])){
 762                 String sql2 = "update orders.inventory set quantity=quantity-100 where ingredient_name='flour'; ";
 763                 String sql3 = "update orders.inventory set quantity=quantity-3 where ingredient_name='eggs'; ";
 764                 String sql4 = "update orders.inventory set quantity=quantity-120 where ingredient_name='butter'; ";
 765                 String sql5 = "update orders.inventory set quantity=quantity-150 where ingredient_name='sugar';";
 766                 String sql6 = "update orders.inventory set quantity=quantity-100 where ingredient_name='choco powder'; "; 
 767                 try (Connection conn = DriverManager.getConnection(jdbcUrl, user, pass); 
 768                 Statement stmt = conn.createStatement();) {
 769       
 770                 stmt.executeUpdate(sql2);
 771                 stmt.executeUpdate(sql3);
 772                 stmt.executeUpdate(sql4);
 773                 stmt.executeUpdate(sql5);
 774                 stmt.executeUpdate(sql6);
 775                 
 776                 System.out.println("Database updated successfully");
 777                 } catch (SQLException ex) {
 778                     Logger.getLogger(MainGUI.class.getName()).log(Level.SEVERE, null, ex);
 779                 }
 780             }
 781             if (items.contains(tokens[4])){
 782                 String sql2 = "update orders.inventory set quantity=quantity-100 where ingredient_name='flour'; ";
 783                 String sql3 = "update orders.inventory set quantity=quantity-2 where ingredient_name='eggs'; ";
 784                 String sql4 = "update orders.inventory set quantity=quantity-100 where ingredient_name='butter'; ";
 785                 String sql5 = "update orders.inventory set quantity=quantity-100 where ingredient_name='sugar';";
 786                 String sql6 = "update orders.inventory set quantity=quantity-50 where ingredient_name='choco chips'; "; 
 787                 try (Connection conn = DriverManager.getConnection(jdbcUrl, user, pass); 
 788                 Statement stmt = conn.createStatement();) {
 789       
 790                 stmt.executeUpdate(sql2);
 791                 stmt.executeUpdate(sql3);
 792                 stmt.executeUpdate(sql4);
 793                 stmt.executeUpdate(sql5);
 794                 stmt.executeUpdate(sql6);
 795                 
 796                 System.out.println("Database updated successfully");
 797                 } catch (SQLException ex) {
 798                     Logger.getLogger(MainGUI.class.getName()).log(Level.SEVERE, null, ex);
 799                 }
 800             }
 801         
 802     
 803         }
 804         //in case the user tries to delete an empty table or does not select a row
 805         else{
 806             if(OrderList.getRowCount()==0){
 807                 //if the table is empty then display this message
 808                 JOptionPane.showMessageDialog(this, "Table is empty.");
 809             }
 810             else{
 811                 //if table is not empty but row is not selected then display this message
 812                 JOptionPane.showMessageDialog(this, "Please select a row to delete.");
 813                 
 814             }
 815         }
 816     }                                      
 817 //i am not able to refactor this as i get an error everytime, however it has not impacted the functionality of my program
 818     private void jTabbedPane1MouseClicked(java.awt.event.MouseEvent evt) {                                          
 819         // TODO add your handling code here:
 820     }                                         
 821 
 822     private void refreshInventoryMouseReleased(java.awt.event.MouseEvent evt) {                                               
 823         //refreshes the rows of the inventory table to bring the newest updates from the database
 824         Connection myConn = null;
 825         Statement myStmt = null;
 826         ResultSet myRs = null;
 827 
 828         String user = "root";
 829         String pass = "paggu2004";
 830    
 831         try {
 832             // 1. Get a connection to database
 833             myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/orders", user, pass);
 834 
 835             // 2. Create a statement
 836             myStmt = myConn.createStatement();
 837 
 838             // 3. Execute SQL query
 839             myRs = myStmt.executeQuery("select * from orders.inventory;");
 840 
 841             // 4. Process the result set
 842             DefaultTableModel tableModel2 = (DefaultTableModel)inventoryTable.getModel();
 843             tableModel2.setRowCount(0);
 844             while (myRs.next()) {
 845                 
 846                 String quantity = myRs.getString("quantity");
 847                 String ingredientName = myRs.getString("ingredient_name");
 848                 String unit = myRs.getString("unit");
 849                 
 850                 String[] tableDate = {ingredientName, quantity, unit};
 851                 tableModel2.addRow(tableDate);  
 852                      
 853             }
 854                 //this warning tells the user that they are running low on any ingredient that is less than 100 in quantity
 855                 for (int i=0;i<tableModel2.getRowCount()-1;i++){
 856                     int x = Integer.parseInt(tableModel2.getValueAt(i,1).toString());
 857                     if (x < 100){
 858                         Component frame = null;
 859                         JOptionPane.showMessageDialog(frame, "Running low on ingredients","Ingredient Warning", JOptionPane.WARNING_MESSAGE);
 860                     }
 861                 }  
 862             
 863 
 864         } catch (SQLException e) {
 865         } finally {
 866             if (myRs != null) {
 867                 try {
 868                     myRs.close();
 869                 } catch (SQLException ex) {
 870                     Logger.getLogger(MainGUI.class.getName()).log(Level.SEVERE, null, ex);
 871                 }
 872             }
 873 
 874             if (myStmt != null) {
 875                 try {
 876                     myStmt.close();
 877                 } catch (SQLException ex) {
 878                     Logger.getLogger(MainGUI.class.getName()).log(Level.SEVERE, null, ex);
 879                 }
 880             }
 881 
 882             if (myConn != null) {
 883                 try {
 884                     myConn.close();
 885                 } catch (SQLException ex) {
 886                     Logger.getLogger(MainGUI.class.getName()).log(Level.SEVERE, null, ex);
 887                 }
 888             }
 889             
 890         }
 891     }                                              
 892 //the rest of these methods all update individual quantities of different ingredients
 893 //i have made them separate methods since each one is controlled by a separate button
 894     private void quantityUpdaterMouseReleased(java.awt.event.MouseEvent evt) {                                              
 895         // TODO add your handling code here:
 896         String quantityUpdate = JOptionPane.showInputDialog(null,"Enter your quantity: ");
 897         
 898         System.out.println("Quantity is: "+quantityUpdate);
 899         Connection myConn = null;
 900         Statement myStmt = null;
 901         ResultSet myRs = null;
 902 
 903         String user = "root";
 904         String pass = "paggu2004";
 905    
 906         try {
 907             // 1. Get a connection to database
 908             myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/orders", user, pass);
 909 
 910             // 2. Create a statement
 911             myStmt = myConn.createStatement();
 912 
 913             // 3. Execute SQL query
 914             myStmt.executeUpdate("update orders.inventory set quantity="+quantityUpdate+" where ingredient_name='sugar';");
 915 
 916             
 917             
 918 
 919         } catch (SQLException ex) {
 920             Logger.getLogger(MainGUI.class.getName()).log(Level.SEVERE, null, ex);
 921         }
 922         
 923     }                                             
 924 
 925     private void quantityUpdater1MouseReleased(java.awt.event.MouseEvent evt) {                                               
 926         // TODO add your handling code here:
 927         String quantityUpdate = JOptionPane.showInputDialog(null,"Enter your quantity: ");
 928         
 929         System.out.println("Quantity is: "+quantityUpdate);
 930         Connection myConn = null;
 931         Statement myStmt = null;
 932         ResultSet myRs = null;
 933 
 934         String user = "root";
 935         String pass = "paggu2004";
 936    
 937         try {
 938             // 1. Get a connection to database
 939             myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/orders", user, pass);
 940 
 941             // 2. Create a statement
 942             myStmt = myConn.createStatement();
 943 
 944             // 3. Execute SQL query
 945             myStmt.executeUpdate("update orders.inventory set quantity="+quantityUpdate+" where ingredient_name='flour';");
 946 
 947             
 948             
 949 
 950         } catch (SQLException ex) {
 951             Logger.getLogger(MainGUI.class.getName()).log(Level.SEVERE, null, ex);
 952         }
 953     }                                              
 954 
 955     private void quantityUpdater2MouseReleased(java.awt.event.MouseEvent evt) {                                               
 956         // TODO add your handling code here:
 957         String quantityUpdate = JOptionPane.showInputDialog(null,"Enter your quantity: ");
 958         
 959         System.out.println("Quantity is: "+quantityUpdate);
 960         Connection myConn = null;
 961         Statement myStmt = null;
 962         ResultSet myRs = null;
 963 
 964         String user = "root";
 965         String pass = "paggu2004";
 966    
 967         try {
 968             // 1. Get a connection to database
 969             myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/orders", user, pass);
 970 
 971             // 2. Create a statement
 972             myStmt = myConn.createStatement();
 973 
 974             // 3. Execute SQL query
 975             myStmt.executeUpdate("update orders.inventory set quantity="+quantityUpdate+" where ingredient_name='salt';");
 976 
 977             
 978             
 979 
 980         } catch (SQLException ex) {
 981             Logger.getLogger(MainGUI.class.getName()).log(Level.SEVERE, null, ex);
 982         }
 983     }                                              
 984 
 985     private void quantityUpdater3MouseReleased(java.awt.event.MouseEvent evt) {                                               
 986         // TODO add your handling code here:
 987         String quantityUpdate = JOptionPane.showInputDialog(null,"Enter your quantity: ");
 988         
 989         System.out.println("Quantity is: "+quantityUpdate);
 990         Connection myConn = null;
 991         Statement myStmt = null;
 992         ResultSet myRs = null;
 993 
 994         String user = "root";
 995         String pass = "paggu2004";
 996    
 997         try {
 998             // 1. Get a connection to database
 999             myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/orders", user, pass);
1000 
1001             // 2. Create a statement
1002             myStmt = myConn.createStatement();
1003 
1004             // 3. Execute SQL query
1005             myStmt.executeUpdate("update orders.inventory set quantity="+quantityUpdate+" where ingredient_name='choco chips';");
1006 
1007             
1008             
1009 
1010         } catch (SQLException ex) {
1011             Logger.getLogger(MainGUI.class.getName()).log(Level.SEVERE, null, ex);
1012         }
1013     }                                              
1014 
1015     private void quantityUpdater4MouseReleased(java.awt.event.MouseEvent evt) {                                               
1016         // TODO add your handling code here:
1017         String quantityUpdate = JOptionPane.showInputDialog(null,"Enter your quantity: ");
1018         
1019         System.out.println("Quantity is: "+quantityUpdate);
1020         Connection myConn = null;
1021         Statement myStmt = null;
1022         ResultSet myRs = null;
1023 
1024         String user = "root";
1025         String pass = "paggu2004";
1026    
1027         try {
1028             // 1. Get a connection to database
1029             myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/orders", user, pass);
1030 
1031             // 2. Create a statement
1032             myStmt = myConn.createStatement();
1033 
1034             // 3. Execute SQL query
1035             myStmt.executeUpdate("update orders.inventory set quantity="+quantityUpdate+" where ingredient_name='milk';");
1036 
1037             
1038             
1039 
1040         } catch (SQLException ex) {
1041             Logger.getLogger(MainGUI.class.getName()).log(Level.SEVERE, null, ex);
1042         }
1043     }                                              
1044 
1045     private void quantityUpdater5MouseReleased(java.awt.event.MouseEvent evt) {                                               
1046         // TODO add your handling code here:
1047         String quantityUpdate = JOptionPane.showInputDialog(null,"Enter your quantity: ");
1048         
1049         System.out.println("Quantity is: "+quantityUpdate);
1050         Connection myConn = null;
1051         Statement myStmt = null;
1052         ResultSet myRs = null;
1053 
1054         String user = "root";
1055         String pass = "paggu2004";
1056    
1057         try {
1058             // 1. Get a connection to database
1059             myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/orders", user, pass);
1060 
1061             // 2. Create a statement
1062             myStmt = myConn.createStatement();
1063 
1064             // 3. Execute SQL query
1065             myStmt.executeUpdate("update orders.inventory set quantity="+quantityUpdate+" where ingredient_name='butter';");
1066 
1067             
1068             
1069 
1070         } catch (SQLException ex) {
1071             Logger.getLogger(MainGUI.class.getName()).log(Level.SEVERE, null, ex);
1072         }
1073     }                                              
1074 
1075     private void quantityUpdater6MouseReleased(java.awt.event.MouseEvent evt) {                                               
1076         // TODO add your handling code here:
1077         String quantityUpdate = JOptionPane.showInputDialog(null,"Enter your quantity: ");
1078         
1079         System.out.println("Quantity is: "+quantityUpdate);
1080         Connection myConn = null;
1081         Statement myStmt = null;
1082         ResultSet myRs = null;
1083 
1084         String user = "root";
1085         String pass = "paggu2004";
1086    
1087         try {
1088             // 1. Get a connection to database
1089             myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/orders", user, pass);
1090 
1091             // 2. Create a statement
1092             myStmt = myConn.createStatement();
1093 
1094             // 3. Execute SQL query
1095             myStmt.executeUpdate("update orders.inventory set quantity="+quantityUpdate+" where ingredient_name='eggs';");
1096 
1097             
1098             
1099 
1100         } catch (SQLException ex) {
1101             Logger.getLogger(MainGUI.class.getName()).log(Level.SEVERE, null, ex);
1102         }
1103     }                                              
1104 
1105     private void quantityUpdater7MouseReleased(java.awt.event.MouseEvent evt) {                                               
1106         // TODO add your handling code here:
1107         String quantityUpdate = JOptionPane.showInputDialog(null,"Enter your quantity: ");
1108         
1109         System.out.println("Quantity is: "+quantityUpdate);
1110         Connection myConn = null;
1111         Statement myStmt = null;
1112         ResultSet myRs = null;
1113 
1114         String user = "root";
1115         String pass = "paggu2004";
1116    
1117         try {
1118             // 1. Get a connection to database
1119             myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/orders", user, pass);
1120 
1121             // 2. Create a statement
1122             myStmt = myConn.createStatement();
1123 
1124             // 3. Execute SQL query
1125             myStmt.executeUpdate("update orders.inventory set quantity="+quantityUpdate+" where ingredient_name='choco powder';");
1126 
1127             
1128             
1129 
1130         } catch (SQLException ex) {
1131             Logger.getLogger(MainGUI.class.getName()).log(Level.SEVERE, null, ex);
1132         }
1133     }                                              
1134   
1135     /**
1136      * @param args the command line arguments
1137      */
1138     public static void main(String args[]) {
1139         /* Set the Nimbus look and feel */
1140         //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
1141         /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
1142          * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
1143          */
1144         try {
1145             for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
1146                 if ("Nimbus".equals(info.getName())) {
1147                     javax.swing.UIManager.setLookAndFeel(info.getClassName());
1148                     break;
1149                 }
1150             }
1151         } catch (ClassNotFoundException ex) {
1152             java.util.logging.Logger.getLogger(MainGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
1153         } catch (InstantiationException ex) {
1154             java.util.logging.Logger.getLogger(MainGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
1155         } catch (IllegalAccessException ex) {
1156             java.util.logging.Logger.getLogger(MainGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
1157         } catch (javax.swing.UnsupportedLookAndFeelException ex) {
1158             java.util.logging.Logger.getLogger(MainGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
1159         }
1160         //</editor-fold>
1161 
1162         /* Create and display the form */
1163         java.awt.EventQueue.invokeLater(new Runnable() {
1164             public void run() {
1165                 new MainGUI().setVisible(true);
1166             }
1167         });
1168         
1169     }
1170     
1171     
1172     // Variables declaration - do not modify                     
1173     private javax.swing.JTable OrderList;
1174     private javax.swing.JLabel RecipeLabel;
1175     private javax.swing.JTable inventoryTable;
1176     private javax.swing.JButton jButton1;
1177     private javax.swing.JLabel jLabel1;
1178     private javax.swing.JLabel jLabel10;
1179     private javax.swing.JLabel jLabel11;
1180     private javax.swing.JLabel jLabel12;
1181     private javax.swing.JLabel jLabel13;
1182     private javax.swing.JLabel jLabel14;
1183     private javax.swing.JLabel jLabel2;
1184     private javax.swing.JLabel jLabel3;
1185     private javax.swing.JLabel jLabel4;
1186     private javax.swing.JLabel jLabel5;
1187     private javax.swing.JLabel jLabel7;
1188     private javax.swing.JLabel jLabel8;
1189     private javax.swing.JLabel jLabel9;
1190     private javax.swing.JPanel jPanel1;
1191     private javax.swing.JPanel jPanel10;
1192     private javax.swing.JPanel jPanel2;
1193     private javax.swing.JPanel jPanel3;
1194     private javax.swing.JPanel jPanel6;
1195     private javax.swing.JPanel jPanel7;
1196     private javax.swing.JPanel jPanel8;
1197     private javax.swing.JPanel jPanel9;
1198     private javax.swing.JScrollPane jScrollPane1;
1199     private javax.swing.JScrollPane jScrollPane2;
1200     private javax.swing.JScrollPane jScrollPane3;
1201     private javax.swing.JScrollPane jScrollPane4;
1202     private javax.swing.JScrollPane jScrollPane5;
1203     private javax.swing.JScrollPane jScrollPane6;
1204     private javax.swing.JScrollPane jScrollPane7;
1205     private javax.swing.JTabbedPane jTabbedPane1;
1206     private javax.swing.JTabbedPane jTabbedPane2;
1207     private javax.swing.JTextArea jTextArea1;
1208     private javax.swing.JTextArea jTextArea2;
1209     private javax.swing.JTextArea jTextArea3;
1210     private javax.swing.JTextArea jTextArea4;
1211     private javax.swing.JTextArea jTextArea5;
1212     private javax.swing.JButton quantityUpdater;
1213     private javax.swing.JButton quantityUpdater1;
1214     private javax.swing.JButton quantityUpdater2;
1215     private javax.swing.JButton quantityUpdater3;
1216     private javax.swing.JButton quantityUpdater4;
1217     private javax.swing.JButton quantityUpdater5;
1218     private javax.swing.JButton quantityUpdater6;
1219     private javax.swing.JButton quantityUpdater7;
1220     private javax.swing.JButton refreshButton;
1221     private javax.swing.JButton refreshInventory;
1222     // End of variables declaration                   
1223 
1224     
1225 }
1226