/Users/johnr/Desktop/IA pdf Downloads/Criteria__P__-_Coding_Project_Upload_all_2022-05-03/Motto_CSIA_04_25/src/main/java/com/mycompany/motto_csia/MainGUIExercises.java
  1 /*
  2  * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
  3  * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/Application.java to edit this template
  4  */
  5 package com.mycompany.motto_csia;
  6 import java.util.LinkedList;
  7 
  8 /**
  9  *
 10  * @author 15245
 11  */
 12 public class MainGUIExercises extends javax.swing.JFrame {
 13 
 14     /**
 15      * Creates new form MainGUIExercises
 16      */
 17     public MainGUIExercises() {
 18         initComponents();
 19         addExistingExercises();
 20         updateExerciseTable();
 21         updateComboBoxes();
 22         
 23     }
 24     
 25     private LinkedList<Exercises> exerciseList = new LinkedList<Exercises>(); //Lists for exercise names, weight types, etc.
 26     private LinkedList<exerciseHistory> exerciseHistoryList = new LinkedList<exerciseHistory>();//list for exercise histories
 27     
 28     
 29     public void addExistingExercises(){
 30         //Adds 4 initial exercises to the program
 31         
 32         Exercises bench = new Exercises("Bench Press","Chest","Barbell");
 33         exerciseHistory benchHistory = new exerciseHistory("Bench Press");
 34         exerciseHistoryList.add(benchHistory);
 35         exerciseList.add(bench);
 36         
 37         Exercises squat = new Exercises("Barbell Squat","Legs","Barbell");
 38         exerciseHistory squatHistory = new exerciseHistory("Barbell Squat");
 39         exerciseHistoryList.add(squatHistory);
 40         exerciseList.add(squat);
 41         
 42         Exercises dl = new Exercises("Deadlift","Full Body","Barbell");
 43         exerciseHistory dlHistory = new exerciseHistory("Deadlift");
 44         exerciseHistoryList.add(dlHistory);
 45         exerciseList.add(dl);
 46         
 47         Exercises curl = new Exercises("Dumbbell Bicep Curl","Arms","Dumbbell");
 48         exerciseHistory curlHistory = new exerciseHistory("Dumbbell Bicep Curl");
 49         exerciseHistoryList.add(curlHistory);
 50         exerciseList.add(curl);
 51 
 52     }
 53   
 54     public void updateExerciseTable(){ //Method to update the table within the main GUI
 55         for(int row = 0; row < exerciseList.size(); row++){
 56             exercisesTable.setValueAt(exerciseList.get(row).getExerciseName(), row, 0);
 57             exercisesTable.setValueAt(exerciseList.get(row).getExerciseBodyPart(), row, 1);
 58             exercisesTable.setValueAt(exerciseList.get(row).getExerciseWeightType(), row, 2);
 59             
 60         }
 61         
 62     }
 63     
 64     public void updateExerciseHistoryTable(){ //Method to update the table within the popup window
 65  
 66         
 67       for(int i = 0; i < exerciseHistoryList.size();i++){
 68              if(exerciseHistoryList.get(i).getExerciseHistoryName().equals(exercisesTable.getValueAt(exercisesTable.getSelectedRow(), 0).toString())){
 69                  for(int j = 0; j < exerciseHistoryList.get(i).getExerciseDates().size(); j++){
 70                     exerciseHistoryTable.setValueAt(null,j,0);
 71                     exerciseHistoryTable.setValueAt(null,j,1);
 72                     exerciseHistoryTable.setValueAt(null,j,2);
 73                     exerciseHistoryTable.setValueAt(null,j,3); 
 74                     
 75                     exerciseHistoryTable.setValueAt(exerciseHistoryList.get(i).getExerciseDates().get(j), j, 0);
 76                     exerciseHistoryTable.setValueAt(exerciseHistoryList.get(i).getWeightUnits().get(j), j, 1);
 77                     exerciseHistoryTable.setValueAt(exerciseHistoryList.get(i).getReps().get(j), j, 2);
 78                     exerciseHistoryTable.setValueAt(exerciseHistoryList.get(i).getWeight().get(j), j, 3);
 79                 }
 80              }
 81         }  
 82     }
 83     
 84     private void updateComboBoxes(){//Method to update the combobox for adding sets to exercises
 85         String[] exerciseNameArray = new String[exerciseList.size()];
 86         
 87         for(int i = 0; i < exerciseList.size();i++){
 88             exerciseNameArray[i] = exerciseList.get(i).getExerciseName();
 89         }        
 90         chooseExerciseComboBox.setModel(new javax.swing.DefaultComboBoxModel<>(exerciseNameArray));
 91     }
 92     
 93     /**
 94      * This method is called from within the constructor to initialize the form.
 95      * WARNING: Do NOT modify this code. The content of this method is always
 96      * regenerated by the Form Editor.
 97      */
 98     @SuppressWarnings("unchecked")
 99     // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
100     private void initComponents() {
101 
102         exerciseHistoryDialog = new javax.swing.JDialog();
103         jScrollPane2 = new javax.swing.JScrollPane();
104         exerciseHistoryTable = new javax.swing.JTable();
105         exerciseHistoryDialogLabel = new javax.swing.JLabel();
106         removeSetButton = new javax.swing.JButton();
107         enterSetOptionPane = new javax.swing.JOptionPane();
108         jTabbedPane1 = new javax.swing.JTabbedPane();
109         enterSetPanel = new javax.swing.JPanel();
110         jLabel4 = new javax.swing.JLabel();
111         jLabel5 = new javax.swing.JLabel();
112         jLabel6 = new javax.swing.JLabel();
113         jLabel7 = new javax.swing.JLabel();
114         jLabel8 = new javax.swing.JLabel();
115         chooseExerciseComboBox = new javax.swing.JComboBox<>();
116         weightUnitComboBox = new javax.swing.JComboBox<>();
117         enterRepsTextField = new javax.swing.JTextField();
118         addSetButton = new javax.swing.JButton();
119         enterSetDateChooser = new com.toedter.calendar.JDateChooser();
120         enterWeightTextField = new javax.swing.JTextField();
121         addExercisePanel = new javax.swing.JPanel();
122         enterExerciseTextField = new javax.swing.JTextField();
123         weightTypeComboBox = new javax.swing.JComboBox<>();
124         bodyPartComboBox = new javax.swing.JComboBox<>();
125         addExerciseButton = new javax.swing.JButton();
126         jLabel1 = new javax.swing.JLabel();
127         jLabel2 = new javax.swing.JLabel();
128         jLabel3 = new javax.swing.JLabel();
129         exerciseHistoryPanel = new javax.swing.JPanel();
130         jScrollPane1 = new javax.swing.JScrollPane();
131         exercisesTable = new javax.swing.JTable();
132         refreshButton = new javax.swing.JButton();
133         viewHistoryButton = new javax.swing.JButton();
134         exerciseSearchButton = new javax.swing.JButton();
135         searchExerciseTextField = new javax.swing.JTextField();
136         menuBar = new javax.swing.JMenuBar();
137         fileMenu = new javax.swing.JMenu();
138         openMenuItem = new javax.swing.JMenuItem();
139         saveMenuItem = new javax.swing.JMenuItem();
140         saveAsMenuItem = new javax.swing.JMenuItem();
141         exitMenuItem = new javax.swing.JMenuItem();
142         editMenu = new javax.swing.JMenu();
143         cutMenuItem = new javax.swing.JMenuItem();
144         copyMenuItem = new javax.swing.JMenuItem();
145         pasteMenuItem = new javax.swing.JMenuItem();
146         deleteMenuItem = new javax.swing.JMenuItem();
147         helpMenu = new javax.swing.JMenu();
148         contentsMenuItem = new javax.swing.JMenuItem();
149         aboutMenuItem = new javax.swing.JMenuItem();
150 
151         exerciseHistoryTable.setModel(new javax.swing.table.DefaultTableModel(
152             new Object [][] {
153                 {null, null, null, null},
154                 {null, null, null, null},
155                 {null, null, null, null},
156                 {null, null, null, null}
157             },
158             new String [] {
159                 "Date", "Weight Unit", "Reps", "Weight"
160             }
161         ) {
162             Class[] types = new Class [] {
163                 java.lang.String.class, java.lang.String.class, java.lang.Integer.class, java.lang.Double.class
164             };
165 
166             public Class getColumnClass(int columnIndex) {
167                 return types [columnIndex];
168             }
169         });
170         jScrollPane2.setViewportView(exerciseHistoryTable);
171 
172         exerciseHistoryDialogLabel.setText("<exercise> History");
173 
174         removeSetButton.setText("Remove Set");
175         removeSetButton.addMouseListener(new java.awt.event.MouseAdapter() {
176             public void mouseReleased(java.awt.event.MouseEvent evt) {
177                 removeSetButtonMouseReleased(evt);
178             }
179         });
180 
181         javax.swing.GroupLayout exerciseHistoryDialogLayout = new javax.swing.GroupLayout(exerciseHistoryDialog.getContentPane());
182         exerciseHistoryDialog.getContentPane().setLayout(exerciseHistoryDialogLayout);
183         exerciseHistoryDialogLayout.setHorizontalGroup(
184             exerciseHistoryDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
185             .addGroup(exerciseHistoryDialogLayout.createSequentialGroup()
186                 .addGap(49, 49, 49)
187                 .addComponent(exerciseHistoryDialogLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)
188                 .addContainerGap(435, Short.MAX_VALUE))
189             .addGroup(exerciseHistoryDialogLayout.createSequentialGroup()
190                 .addGap(24, 24, 24)
191                 .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 433, javax.swing.GroupLayout.PREFERRED_SIZE)
192                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
193                 .addComponent(removeSetButton)
194                 .addGap(20, 20, 20))
195         );
196         exerciseHistoryDialogLayout.setVerticalGroup(
197             exerciseHistoryDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
198             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, exerciseHistoryDialogLayout.createSequentialGroup()
199                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
200                 .addComponent(exerciseHistoryDialogLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
201                 .addGroup(exerciseHistoryDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
202                     .addGroup(exerciseHistoryDialogLayout.createSequentialGroup()
203                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
204                         .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 280, javax.swing.GroupLayout.PREFERRED_SIZE))
205                     .addGroup(exerciseHistoryDialogLayout.createSequentialGroup()
206                         .addGap(42, 42, 42)
207                         .addComponent(removeSetButton)))
208                 .addGap(26, 26, 26))
209         );
210 
211         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
212 
213         jTabbedPane1.addMouseListener(new java.awt.event.MouseAdapter() {
214             public void mouseReleased(java.awt.event.MouseEvent evt) {
215                 jTabbedPane1MouseReleased(evt);
216             }
217         });
218 
219         enterSetPanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
220 
221         jLabel4.setText("Choose Exercise");
222 
223         jLabel5.setText("Weight Unit");
224 
225         jLabel6.setText("Reps:");
226 
227         jLabel7.setText("Date:");
228 
229         jLabel8.setText("Weight");
230 
231         chooseExerciseComboBox.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "x" }));
232 
233         weightUnitComboBox.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "kg", "lbs" }));
234 
235         enterRepsTextField.setText("Enter Reps");
236 
237         addSetButton.setText("Add Set");
238         addSetButton.addMouseListener(new java.awt.event.MouseAdapter() {
239             public void mouseReleased(java.awt.event.MouseEvent evt) {
240                 addSetButtonMouseReleased(evt);
241             }
242         });
243         addSetButton.addActionListener(new java.awt.event.ActionListener() {
244             public void actionPerformed(java.awt.event.ActionEvent evt) {
245                 addSetButtonActionPerformed(evt);
246             }
247         });
248 
249         enterWeightTextField.setText("Enter Weight");
250 
251         javax.swing.GroupLayout enterSetPanelLayout = new javax.swing.GroupLayout(enterSetPanel);
252         enterSetPanel.setLayout(enterSetPanelLayout);
253         enterSetPanelLayout.setHorizontalGroup(
254             enterSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
255             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, enterSetPanelLayout.createSequentialGroup()
256                 .addContainerGap(118, Short.MAX_VALUE)
257                 .addGroup(enterSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
258                     .addGroup(enterSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
259                         .addComponent(jLabel4)
260                         .addComponent(jLabel5)
261                         .addGroup(enterSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
262                             .addComponent(jLabel7)
263                             .addComponent(jLabel6))
264                         .addComponent(jLabel8))
265                     .addGroup(enterSetPanelLayout.createSequentialGroup()
266                         .addComponent(addSetButton)
267                         .addGap(22, 22, 22)))
268                 .addGap(66, 66, 66)
269                 .addGroup(enterSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
270                     .addComponent(enterWeightTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
271                     .addComponent(enterRepsTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
272                     .addComponent(weightUnitComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
273                     .addComponent(chooseExerciseComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
274                     .addComponent(enterSetDateChooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
275                 .addGap(102, 102, 102))
276         );
277         enterSetPanelLayout.setVerticalGroup(
278             enterSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
279             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, enterSetPanelLayout.createSequentialGroup()
280                 .addContainerGap(78, Short.MAX_VALUE)
281                 .addGroup(enterSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
282                     .addComponent(jLabel4)
283                     .addComponent(chooseExerciseComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
284                 .addGap(18, 18, 18)
285                 .addGroup(enterSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
286                     .addComponent(jLabel5)
287                     .addComponent(weightUnitComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
288                 .addGap(18, 18, 18)
289                 .addGroup(enterSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
290                     .addComponent(jLabel6)
291                     .addComponent(enterRepsTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
292                 .addGap(25, 25, 25)
293                 .addGroup(enterSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
294                     .addComponent(enterWeightTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
295                     .addComponent(jLabel8))
296                 .addGap(18, 18, 18)
297                 .addGroup(enterSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
298                     .addComponent(enterSetDateChooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
299                     .addComponent(jLabel7))
300                 .addGap(21, 21, 21)
301                 .addComponent(addSetButton)
302                 .addGap(68, 68, 68))
303         );
304 
305         jTabbedPane1.addTab("Enter Set", enterSetPanel);
306 
307         addExercisePanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
308 
309         enterExerciseTextField.setText("Enter Exercise Name");
310         enterExerciseTextField.addActionListener(new java.awt.event.ActionListener() {
311             public void actionPerformed(java.awt.event.ActionEvent evt) {
312                 enterExerciseTextFieldActionPerformed(evt);
313             }
314         });
315 
316         weightTypeComboBox.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Barbell", "Dumbell", "Machine (Cable)", "Machine (Plate)", "Cable" }));
317 
318         bodyPartComboBox.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Arms", "Chest", "Back", "Shoulders", "Legs", "Full Body", "Other" }));
319         bodyPartComboBox.addActionListener(new java.awt.event.ActionListener() {
320             public void actionPerformed(java.awt.event.ActionEvent evt) {
321                 bodyPartComboBoxActionPerformed(evt);
322             }
323         });
324 
325         addExerciseButton.setText("Add Exercise");
326         addExerciseButton.addMouseListener(new java.awt.event.MouseAdapter() {
327             public void mouseReleased(java.awt.event.MouseEvent evt) {
328                 addExerciseButtonMouseReleased(evt);
329             }
330         });
331         addExerciseButton.addActionListener(new java.awt.event.ActionListener() {
332             public void actionPerformed(java.awt.event.ActionEvent evt) {
333                 addExerciseButtonActionPerformed(evt);
334             }
335         });
336 
337         jLabel1.setText("Exercise Name:");
338 
339         jLabel2.setText("Body Part:");
340 
341         jLabel3.setText("Weight Type");
342 
343         javax.swing.GroupLayout addExercisePanelLayout = new javax.swing.GroupLayout(addExercisePanel);
344         addExercisePanel.setLayout(addExercisePanelLayout);
345         addExercisePanelLayout.setHorizontalGroup(
346             addExercisePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
347             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, addExercisePanelLayout.createSequentialGroup()
348                 .addContainerGap(90, Short.MAX_VALUE)
349                 .addGroup(addExercisePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
350                     .addGroup(addExercisePanelLayout.createSequentialGroup()
351                         .addGroup(addExercisePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
352                             .addComponent(jLabel1)
353                             .addComponent(jLabel2)
354                             .addComponent(jLabel3))
355                         .addGap(52, 52, 52)
356                         .addGroup(addExercisePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
357                             .addComponent(enterExerciseTextField)
358                             .addComponent(bodyPartComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
359                             .addComponent(weightTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)))
360                     .addGroup(addExercisePanelLayout.createSequentialGroup()
361                         .addGap(59, 59, 59)
362                         .addComponent(addExerciseButton)))
363                 .addGap(86, 86, 86))
364         );
365         addExercisePanelLayout.setVerticalGroup(
366             addExercisePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
367             .addGroup(addExercisePanelLayout.createSequentialGroup()
368                 .addGap(120, 120, 120)
369                 .addGroup(addExercisePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
370                     .addComponent(jLabel1)
371                     .addComponent(enterExerciseTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
372                 .addGap(18, 18, 18)
373                 .addGroup(addExercisePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
374                     .addComponent(jLabel2)
375                     .addComponent(bodyPartComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
376                 .addGap(18, 18, 18)
377                 .addGroup(addExercisePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
378                     .addComponent(jLabel3)
379                     .addComponent(weightTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
380                 .addGap(46, 46, 46)
381                 .addComponent(addExerciseButton, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
382                 .addContainerGap(71, Short.MAX_VALUE))
383         );
384 
385         jTabbedPane1.addTab("Add Exercise", addExercisePanel);
386 
387         exerciseHistoryPanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
388 
389         exercisesTable.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
390         exercisesTable.setModel(new javax.swing.table.DefaultTableModel(
391             new Object [][] {
392                 {null, null, null},
393                 {null, null, null},
394                 {null, null, null},
395                 {null, null, null},
396                 {null, null, null},
397                 {null, null, null},
398                 {null, null, null},
399                 {null, null, null},
400                 {null, null, null},
401                 {null, null, null},
402                 {null, null, null},
403                 {null, null, null},
404                 {null, null, null},
405                 {null, null, null},
406                 {null, null, null},
407                 {null, null, null},
408                 {null, null, null},
409                 {null, null, null},
410                 {null, null, null},
411                 {null, null, null}
412             },
413             new String [] {
414                 "Exercise Name", "Body Part", "Weight Type"
415             }
416         ) {
417             Class[] types = new Class [] {
418                 java.lang.String.class, java.lang.String.class, java.lang.String.class
419             };
420 
421             public Class getColumnClass(int columnIndex) {
422                 return types [columnIndex];
423             }
424         });
425         exercisesTable.setGridColor(new java.awt.Color(0, 0, 0));
426         exercisesTable.addMouseListener(new java.awt.event.MouseAdapter() {
427             public void mouseClicked(java.awt.event.MouseEvent evt) {
428                 exercisesTableMouseClicked(evt);
429             }
430         });
431         jScrollPane1.setViewportView(exercisesTable);
432 
433         refreshButton.setText("Refresh");
434         refreshButton.addActionListener(new java.awt.event.ActionListener() {
435             public void actionPerformed(java.awt.event.ActionEvent evt) {
436                 refreshButtonActionPerformed(evt);
437             }
438         });
439 
440         viewHistoryButton.setText("View History");
441         viewHistoryButton.addMouseListener(new java.awt.event.MouseAdapter() {
442             public void mouseReleased(java.awt.event.MouseEvent evt) {
443                 viewHistoryButtonMouseReleased(evt);
444             }
445         });
446 
447         exerciseSearchButton.setText("Name Search");
448         exerciseSearchButton.addMouseListener(new java.awt.event.MouseAdapter() {
449             public void mouseReleased(java.awt.event.MouseEvent evt) {
450                 exerciseSearchButtonMouseReleased(evt);
451             }
452         });
453         exerciseSearchButton.addActionListener(new java.awt.event.ActionListener() {
454             public void actionPerformed(java.awt.event.ActionEvent evt) {
455                 exerciseSearchButtonActionPerformed(evt);
456             }
457         });
458 
459         searchExerciseTextField.setText("Exercise Name");
460 
461         javax.swing.GroupLayout exerciseHistoryPanelLayout = new javax.swing.GroupLayout(exerciseHistoryPanel);
462         exerciseHistoryPanel.setLayout(exerciseHistoryPanelLayout);
463         exerciseHistoryPanelLayout.setHorizontalGroup(
464             exerciseHistoryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
465             .addGroup(exerciseHistoryPanelLayout.createSequentialGroup()
466                 .addGap(15, 15, 15)
467                 .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 319, javax.swing.GroupLayout.PREFERRED_SIZE)
468                 .addGroup(exerciseHistoryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
469                     .addGroup(exerciseHistoryPanelLayout.createSequentialGroup()
470                         .addGroup(exerciseHistoryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
471                             .addGroup(exerciseHistoryPanelLayout.createSequentialGroup()
472                                 .addGap(24, 24, 24)
473                                 .addGroup(exerciseHistoryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
474                                     .addComponent(viewHistoryButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
475                                     .addComponent(refreshButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
476                             .addGroup(exerciseHistoryPanelLayout.createSequentialGroup()
477                                 .addGap(18, 18, 18)
478                                 .addComponent(exerciseSearchButton)))
479                         .addGap(0, 11, Short.MAX_VALUE))
480                     .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, exerciseHistoryPanelLayout.createSequentialGroup()
481                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
482                         .addComponent(searchExerciseTextField)))
483                 .addContainerGap())
484         );
485         exerciseHistoryPanelLayout.setVerticalGroup(
486             exerciseHistoryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
487             .addGroup(exerciseHistoryPanelLayout.createSequentialGroup()
488                 .addContainerGap()
489                 .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
490                 .addContainerGap())
491             .addGroup(exerciseHistoryPanelLayout.createSequentialGroup()
492                 .addGap(82, 82, 82)
493                 .addComponent(searchExerciseTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
494                 .addGap(18, 18, 18)
495                 .addComponent(exerciseSearchButton)
496                 .addGap(49, 49, 49)
497                 .addComponent(refreshButton)
498                 .addGap(40, 40, 40)
499                 .addComponent(viewHistoryButton)
500                 .addContainerGap(103, Short.MAX_VALUE))
501         );
502 
503         jTabbedPane1.addTab("Exercise History", exerciseHistoryPanel);
504 
505         fileMenu.setMnemonic('f');
506         fileMenu.setText("File");
507 
508         openMenuItem.setMnemonic('o');
509         openMenuItem.setText("Open");
510         fileMenu.add(openMenuItem);
511 
512         saveMenuItem.setMnemonic('s');
513         saveMenuItem.setText("Save");
514         fileMenu.add(saveMenuItem);
515 
516         saveAsMenuItem.setMnemonic('a');
517         saveAsMenuItem.setText("Save As ...");
518         saveAsMenuItem.setDisplayedMnemonicIndex(5);
519         fileMenu.add(saveAsMenuItem);
520 
521         exitMenuItem.setMnemonic('x');
522         exitMenuItem.setText("Exit");
523         exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
524             public void actionPerformed(java.awt.event.ActionEvent evt) {
525                 exitMenuItemActionPerformed(evt);
526             }
527         });
528         fileMenu.add(exitMenuItem);
529 
530         menuBar.add(fileMenu);
531 
532         editMenu.setMnemonic('e');
533         editMenu.setText("Edit");
534 
535         cutMenuItem.setMnemonic('t');
536         cutMenuItem.setText("Cut");
537         editMenu.add(cutMenuItem);
538 
539         copyMenuItem.setMnemonic('y');
540         copyMenuItem.setText("Copy");
541         editMenu.add(copyMenuItem);
542 
543         pasteMenuItem.setMnemonic('p');
544         pasteMenuItem.setText("Paste");
545         editMenu.add(pasteMenuItem);
546 
547         deleteMenuItem.setMnemonic('d');
548         deleteMenuItem.setText("Delete");
549         editMenu.add(deleteMenuItem);
550 
551         menuBar.add(editMenu);
552 
553         helpMenu.setMnemonic('h');
554         helpMenu.setText("Help");
555 
556         contentsMenuItem.setMnemonic('c');
557         contentsMenuItem.setText("Contents");
558         helpMenu.add(contentsMenuItem);
559 
560         aboutMenuItem.setMnemonic('a');
561         aboutMenuItem.setText("About");
562         helpMenu.add(aboutMenuItem);
563 
564         menuBar.add(helpMenu);
565 
566         setJMenuBar(menuBar);
567 
568         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
569         getContentPane().setLayout(layout);
570         layout.setHorizontalGroup(
571             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
572             .addGroup(layout.createSequentialGroup()
573                 .addGap(22, 22, 22)
574                 .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 480, javax.swing.GroupLayout.PREFERRED_SIZE)
575                 .addContainerGap(23, Short.MAX_VALUE))
576         );
577         layout.setVerticalGroup(
578             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
579             .addGroup(layout.createSequentialGroup()
580                 .addGap(19, 19, 19)
581                 .addComponent(jTabbedPane1)
582                 .addGap(16, 16, 16))
583         );
584 
585         pack();
586     }// </editor-fold>                        
587 
588     private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {                                             
589         System.exit(0);
590     }                                            
591   
592     private void enterExerciseTextFieldActionPerformed(java.awt.event.ActionEvent evt) {                                                       
593         // TODO add your handling code here:
594     }                                                      
595 
596     private void addExerciseButtonActionPerformed(java.awt.event.ActionEvent evt) {                                                  
597         
598     }                                                 
599 
600     private void bodyPartComboBoxActionPerformed(java.awt.event.ActionEvent evt) {                                                 
601         // TODO add your handling code here:
602     }                                                
603 
604     private void refreshButtonActionPerformed(java.awt.event.ActionEvent evt) {                                              
605         updateExerciseTable();
606     }                                             
607 
608     private void exerciseSearchButtonActionPerformed(java.awt.event.ActionEvent evt) {                                                     
609         // TODO add your handling code here:
610     }                                                    
611 
612     private void exerciseSearchButtonMouseReleased(java.awt.event.MouseEvent evt) {                                                   
613         for(int i = 0; i < exerciseList.size();i++){
614              if(exerciseList.get(i).getExerciseName().equals(searchExerciseTextField.getText())){
615                 for(int row = 0; row < exerciseList.size(); row++){
616                     exercisesTable.setValueAt(null, row, 0);
617                     exercisesTable.setValueAt(null, row, 1);
618                     exercisesTable.setValueAt(null, row, 2); 
619                 }
620                 exercisesTable.setValueAt(exerciseList.get(i).getExerciseName(), 0, 0);
621                 exercisesTable.setValueAt(exerciseList.get(i).getExerciseBodyPart(), 0, 1);
622                 exercisesTable.setValueAt(exerciseList.get(i).getExerciseWeightType(), 0, 2);
623              }
624         }
625     }                                                  
626 
627     private void exercisesTableMouseClicked(java.awt.event.MouseEvent evt) {                                            
628         
629     }                                           
630 
631     private void addSetButtonMouseReleased(java.awt.event.MouseEvent evt) {                                           
632 
633         try{
634             for(int i = 0; i < exerciseHistoryList.size();i++){
635                  if(exerciseHistoryList.get(i).getExerciseHistoryName().equals(chooseExerciseComboBox.getSelectedItem().toString())){
636                     exerciseHistoryList.get(i).addSet(enterSetDateChooser.getDate().toString(),weightUnitComboBox.getSelectedItem().toString(),Integer.parseInt(enterRepsTextField.getText()),Double.parseDouble(enterWeightTextField.getText()));
637                  }
638 
639             }
640         }
641         catch(NumberFormatException ex){
642         enterSetOptionPane.showMessageDialog(this, "One or more inputs are invalid. Try again");
643     }
644 
645        
646     }                                          
647 
648     private void jTabbedPane1MouseReleased(java.awt.event.MouseEvent evt) {                                           
649         
650     }                                          
651 
652     private void addExerciseButtonMouseReleased(java.awt.event.MouseEvent evt) {                                                
653         //Adds exercise to the exercise list and exercise history list
654         
655         Exercises e = new Exercises(enterExerciseTextField.getText(),bodyPartComboBox.getSelectedItem().toString(),weightTypeComboBox.getSelectedItem().toString());
656         exerciseHistory a  = new exerciseHistory(enterExerciseTextField.getText());
657         exerciseHistoryList.add(a);
658         exerciseList.add(e);
659         updateExerciseTable();
660         updateComboBoxes();
661         //System.out.println(e.getExerciseName() + " " + e.getExercizeBodyPart() + " " + e.getExerciseWeightType());
662     }                                               
663 
664     private void viewHistoryButtonMouseReleased(java.awt.event.MouseEvent evt) {                                                
665   
666         updateExerciseHistoryTable();
667         
668         exerciseHistoryDialog.setVisible(true);
669         
670         exerciseHistoryDialogLabel.setText(exercisesTable.getValueAt(exercisesTable.getSelectedRow(), 0).toString() + " History"); //Changing the label in the dialog window
671         
672     }                                               
673 
674     private void removeSetButtonMouseReleased(java.awt.event.MouseEvent evt) {                                              
675         
676       for(int i = 0; i < exerciseHistoryList.size();i++){ // For Loop For Clearing Table
677              if(exerciseHistoryList.get(i).getExerciseHistoryName().equals(exercisesTable.getValueAt(exercisesTable.getSelectedRow(), 0).toString())){
678                  for(int j = 0; j < exerciseHistoryList.get(i).getExerciseDates().size(); j++){
679                     exerciseHistoryTable.setValueAt(null,j,0);
680                     exerciseHistoryTable.setValueAt(null,j,1);
681                     exerciseHistoryTable.setValueAt(null,j,2);
682                     exerciseHistoryTable.setValueAt(null,j,3); 
683                    
684                 }
685              }
686         }
687       
688       for(int i = 0; i < exerciseHistoryList.size();i++){ //For Loop for removing from the arraylists and updating the table
689              if(exerciseHistoryList.get(i).getExerciseHistoryName().equals(exercisesTable.getValueAt(exercisesTable.getSelectedRow(), 0).toString())){
690                 exerciseHistoryList.get(i).removeSet(exerciseHistoryTable.getSelectedColumn());
691                  for(int j = 0; j < exerciseHistoryList.get(i).getExerciseDates().size(); j++){
692                     
693                     exerciseHistoryTable.setValueAt(exerciseHistoryList.get(i).getExerciseDates().get(j), j, 0);
694                     exerciseHistoryTable.setValueAt(exerciseHistoryList.get(i).getWeightUnits().get(j), j, 1);
695                     exerciseHistoryTable.setValueAt(exerciseHistoryList.get(i).getReps().get(j), j, 2);
696                     exerciseHistoryTable.setValueAt(exerciseHistoryList.get(i).getWeight().get(j), j, 3);
697                 }
698              }
699         }
700       
701       
702     }                                             
703 
704     private void addSetButtonActionPerformed(java.awt.event.ActionEvent evt) {                                             
705         // TODO add your handling code here:
706     }                                            
707 
708     /**
709      * @param args the command line arguments
710      */
711     public static void main(String args[]) {
712         /* Set the Nimbus look and feel */
713         //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
714         /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
715          * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
716          */
717         try {
718             for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
719                 if ("Nimbus".equals(info.getName())) {
720                     javax.swing.UIManager.setLookAndFeel(info.getClassName());
721                     break;
722                 }
723             }
724         } catch (ClassNotFoundException ex) {
725             java.util.logging.Logger.getLogger(MainGUIExercises.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
726         } catch (InstantiationException ex) {
727             java.util.logging.Logger.getLogger(MainGUIExercises.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
728         } catch (IllegalAccessException ex) {
729             java.util.logging.Logger.getLogger(MainGUIExercises.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
730         } catch (javax.swing.UnsupportedLookAndFeelException ex) {
731             java.util.logging.Logger.getLogger(MainGUIExercises.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
732         }
733         //</editor-fold>
734 
735         /* Create and display the form */
736         java.awt.EventQueue.invokeLater(new Runnable() {
737             public void run() {
738                 new MainGUIExercises().setVisible(true);
739             }
740         });
741     }
742 
743     // Variables declaration - do not modify                     
744     private javax.swing.JMenuItem aboutMenuItem;
745     private javax.swing.JButton addExerciseButton;
746     private javax.swing.JPanel addExercisePanel;
747     private javax.swing.JButton addSetButton;
748     private javax.swing.JComboBox<String> bodyPartComboBox;
749     private javax.swing.JComboBox<String> chooseExerciseComboBox;
750     private javax.swing.JMenuItem contentsMenuItem;
751     private javax.swing.JMenuItem copyMenuItem;
752     private javax.swing.JMenuItem cutMenuItem;
753     private javax.swing.JMenuItem deleteMenuItem;
754     private javax.swing.JMenu editMenu;
755     private javax.swing.JTextField enterExerciseTextField;
756     private javax.swing.JTextField enterRepsTextField;
757     private com.toedter.calendar.JDateChooser enterSetDateChooser;
758     private javax.swing.JOptionPane enterSetOptionPane;
759     private javax.swing.JPanel enterSetPanel;
760     private javax.swing.JTextField enterWeightTextField;
761     private javax.swing.JDialog exerciseHistoryDialog;
762     private javax.swing.JLabel exerciseHistoryDialogLabel;
763     private javax.swing.JPanel exerciseHistoryPanel;
764     private javax.swing.JTable exerciseHistoryTable;
765     private javax.swing.JButton exerciseSearchButton;
766     private javax.swing.JTable exercisesTable;
767     private javax.swing.JMenuItem exitMenuItem;
768     private javax.swing.JMenu fileMenu;
769     private javax.swing.JMenu helpMenu;
770     private javax.swing.JLabel jLabel1;
771     private javax.swing.JLabel jLabel2;
772     private javax.swing.JLabel jLabel3;
773     private javax.swing.JLabel jLabel4;
774     private javax.swing.JLabel jLabel5;
775     private javax.swing.JLabel jLabel6;
776     private javax.swing.JLabel jLabel7;
777     private javax.swing.JLabel jLabel8;
778     private javax.swing.JScrollPane jScrollPane1;
779     private javax.swing.JScrollPane jScrollPane2;
780     private javax.swing.JTabbedPane jTabbedPane1;
781     private javax.swing.JMenuBar menuBar;
782     private javax.swing.JMenuItem openMenuItem;
783     private javax.swing.JMenuItem pasteMenuItem;
784     private javax.swing.JButton refreshButton;
785     private javax.swing.JButton removeSetButton;
786     private javax.swing.JMenuItem saveAsMenuItem;
787     private javax.swing.JMenuItem saveMenuItem;
788     private javax.swing.JTextField searchExerciseTextField;
789     private javax.swing.JButton viewHistoryButton;
790     private javax.swing.JComboBox<String> weightTypeComboBox;
791     private javax.swing.JComboBox<String> weightUnitComboBox;
792     // End of variables declaration                   
793 
794 }
795