method flow control
<p>I have a form that give <code>Fname</code> and <code>Lname</code> and <code>Date</code> and a method to write this information to a file.</p>

<p>If <code>Fname</code> or <code>Lname</code> contain digit, the program should display an error message and not run all below statements ,(like write to file and generate random number and...), and not exit.
since i dont know how to do like this, in my code i write if Fname or Lname have digit, exit !</p>

<pre><code>private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)   {                                         
    try{
        setFName(jTextField1.getText());
        if(havedigit(getFName())==true) { 
            System.exit(1);
        }
        setLName(jTextField2.getText());
        if(havedigit(lastName)==true) {
            System.exit(1);
        }
        WriteToFile(getFName());
        WriteToFile(getLName());
        setDate(Integer.parseInt(jTextField3.getText()));
        WriteToFile(String.valueOf(getDate()));
        Random rnd1=new Random();
        Registration_Number=rnd1.nextInt(100);
        setRegNum(Registration_Number);
        WriteToFile(String.valueOf(getRegNum()));
        jLabel6.setText(String.valueOf(getRegNum()));
    }
    catch(Exception e){
        jLabel6.setText("Error!");
    }
}                                        

public boolean havedigit(String in){
    for(int i=0;i&lt;in.length();i++){
        if(Character.isDigit(in.charAt(i)))  return true;
    }
    return false;
}
</code></pre>

<p>please help!</p>
