private void deleteBtnActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_deleteBtnActionPerformed // TODO add your handling code here: int selectedRow = vitalSignTable.getSelectedRow(); if (selectedRow >= 0) { int dialogButton = JOptionPane.YES_NO_OPTION; int dialogResult = JOptionPane.showConfirmDialog( this, "Are you sure you want to delete this row ?", "Warning", dialogButton); if (dialogResult == JOptionPane.YES_OPTION) { VitalSign vs = (VitalSign) vitalSignTable.getValueAt(selectedRow, 4); vitalSignHistory.deleteVitalSign(vs); // Populate the new Table populateTable(); respRateTextField.setText(""); heartRateTextField.setText(""); bpTextField.setText(""); weightTextField.setText(""); timeTextField.setText(""); } } else { JOptionPane.showMessageDialog( this, "Please select a row!", "Warning", JOptionPane.WARNING_MESSAGE); } } // GEN-LAST:event_deleteBtnActionPerformed
public void populateTable() { DefaultTableModel dtm = (DefaultTableModel) vitalSignTable.getModel(); dtm.setRowCount(0); for (VitalSign vs : vitalSignHistory.getVitalSignList()) { Object row[] = new Object[6]; row[0] = vs.getRespRate(); row[1] = vs.getHeartRate(); row[2] = vs.getBp(); row[3] = vs.getWeight(); row[4] = vs; if (profile.getAge() >= 1 && profile.getAge() <= 3) { if (((vs.getRespRate() < 20) || (vs.getRespRate() > 30)) || (vs.getHeartRate() < 80) || (vs.getHeartRate() > 130) || (vs.getBp() < 80) || (vs.getBp() > 110) || (vs.getWeight() < 22) || (vs.getWeight() > 31)) { row[5] = "Abnormal"; } else { row[5] = "Normal"; } } else if (profile.getAge() >= 4 && profile.getAge() <= 5) { if (((vs.getRespRate() < 20) || (vs.getRespRate() > 30)) || (vs.getHeartRate() < 80) || (vs.getHeartRate() > 120) || (vs.getBp() < 80) || (vs.getBp() >= 110) || (vs.getWeight() < 31) || (vs.getWeight() > 40)) { row[5] = "Abormal"; } else { row[5] = "Normal"; } } else if (profile.getAge() >= 6 && profile.getAge() <= 12) { if (((vs.getRespRate() < 20) || (vs.getRespRate() > 30)) || (vs.getHeartRate() < 70) || (vs.getHeartRate() > 110) || (vs.getBp() < 80) || (vs.getBp() >= 120) || (vs.getWeight() < 41) || (vs.getWeight() >= 92)) { row[5] = "Abnormal"; } else { row[5] = "Normal"; } } else { if (((vs.getRespRate() < 12) || (vs.getRespRate() > 20)) || (vs.getHeartRate() < 55) || (vs.getHeartRate() > 105) || (vs.getBp() < 110) || (vs.getBp() >= 120) || (vs.getWeight() > 110)) { row[5] = "Abnormal"; } else { row[5] = "Normal"; } } dtm.addRow(row); } }