private class btnCalculateListener implements ActionListener { public void actionPerformed(ActionEvent e) { double num1, num2, num3; try { num1 = Double.parseDouble(txtNumber1.getText()); } catch (Exception ex) { JOptionPane.showMessageDialog(GUIWindow.this, "Please enter an integer or a decimal in the first number box", programTitle, JOptionPane.ERROR_MESSAGE); return; } try { num2 = Double.parseDouble(txtNumber2.getText()); } catch (Exception ex) { JOptionPane.showMessageDialog(GUIWindow.this, "Please enter an integer or a decimal in the second number box", programTitle, JOptionPane.ERROR_MESSAGE); return; } try { num3 = Double.parseDouble(txtNumber3.getText()); } catch (Exception ex) { JOptionPane.showMessageDialog(GUIWindow.this, "Please enter an integer or a decimal in the third number box", programTitle, JOptionPane.ERROR_MESSAGE); return; } double average = (num1+num2+num3)/3.0; lblResult.setText("" + average); } }