private void metricSelectorActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_metricSelectorActionPerformed
   setSubstance();
   String selected = (String) metricSelector.getSelectedItem();
   if (selected.equalsIgnoreCase("Final Value")) {
     metric = new FinalValue(substance);
   } else if (selected.equalsIgnoreCase("Maximum Value")) {
     metric = new MaximumValue(substance);
   } else if (selected.equalsIgnoreCase("Minimum Value")) {
     metric = new MinimumValue(substance);
   } else if (selected.equalsIgnoreCase("Range")) {
     metric = new dynetica.objective.Range(substance);
   } else if (selected.equalsIgnoreCase("Maximum Rate")) {
     metric = new MaximumRate(substance);
   } else if (selected.equalsIgnoreCase("Area Under Curve")) {
     metric = new AreaUnderCurve(substance);
   } else if (selected.equalsIgnoreCase("Time to Steady State")) {
     double fraction = -1;
     while ((fraction < 0) || (fraction > 1)) {
       String fractionInput =
           JOptionPane.showInputDialog(
               this, "Fraction of steady state reached? (Between 0 and 1) ");
       fraction = Double.parseDouble(fractionInput);
     }
     metric = new TimeToSteadyState(substance, fraction);
   }
 } // GEN-LAST:event_metricSelectorActionPerformed
 private void addButtonActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_addButtonActionPerformed
   if (targetObjective == null) {
     JOptionPane.showMessageDialog(
         null, "Warning: All fields must be defined.", "Warning", JOptionPane.WARNING_MESSAGE);
     return;
   }
   psdre.addObjective(targetObjective);
   frame.setVisible(false);
   frame.dispose();
 } // GEN-LAST:event_addButtonActionPerformed