Just skimming, but BlackCat is right -- after the exception is caught, the code resumes execution immediately after the catch.
Which is also what happens right after the if(true condition) statement;, Asher.
double paymentValue; double timeValue; try { paymentValue = Double.parseDouble(payment.getText()): } catch (NumberFormatException e) { JOptionPane.showMessageDialog(frame,"Invalid payment amount. Must be a number."); return; } try { timeValue = Double.parseDouble(time.getText()): } catch (NumberFormatException e) { JOptionPane.showMessageDialog(frame,"Invalid time amount. Must be a number."); return; } //Creates new object fram of Jframe class JFrame frame = new JFrame("Error"); if (paymentValue <= 0) { JOptionPane.showMessageDialog(frame,"Invalid payment amount. Must be greater than zero."); } else { if (timeValue <= 0) { JOptionPane.showMessageDialog(frame,"Invalid time amount. Must be greater than zero."); } else { ptArray[index][0] = timeValue; ptArray[index][0] = timeValue; index++; } }
double paymentValue = Double.parseDouble(payment.getText()); double timeValue = Double.parseDouble(time.getText()); if (paymentValue <= 0) { JOptionPane.showMessageDialog(new JFrame("Error"),"Invalid payment amount. Must be greater than zero."); } else { if (timeValue <= 0) { JOptionPane.showMessageDialog(new JFrame("Error"),"Invalid time amount. Must be greater than zero."); } else { ptArray[index][0] = timeValue; ptArray[index][0] = timeValue; index++; } } }
try { double paymentValue = Double.parseDouble(payment.getText()); double timeValue = Double.parseDouble(time.getText()); if (paymentValue <= 0) { JOptionPane.showMessageDialog(new JFrame("Error"),"Invalid payment amount. Must be greater than zero."); } else { if (timeValue <= 0) { JOptionPane.showMessageDialog(new JFrame("Error"),"Invalid time amount. Must be greater than zero."); } else { ptArray[index][0] = timeValue; ptArray[index][0] = timeValue; index++; } } } catch (Exception e) { JOptionPane.showMessageDialog(new JFrame("Error"),"Invalid input."); }
public void showError(String errorText) { JOptionPane.showMessageDialog(new JFrame("Error"),errorText); }
public void showError(String errorText) { JOptionPane.showMessageDialog(new JFrame("Error"),errorText); }
Comment