everyone, I am writing an interactive graphical user interface program. basically it accepts all inputs and display information on TextArea below. but it will validate all inputs if it is empty or null. My question is that, for example, first name is empty, how can it loop back at textField (first name field)? and retype again without further going ?
I was using a do while loop, but it only works when I use JOptionPane windows to pop out. let me clarify my question: What I want is that when the first name field is null or empty, the user needs to retype again from textfield instead of a window, I don't want "JOPtionPane.showmessageDialog " window coming out Thanks
image is here
do{
whetherContinue=true;
FName=TxtFname.getText();
if(TxtFname.getText().isEmpty()){
FName = JOptionPane.showInputDialog("Please type your First Name");
TxtFname.setText(FName);
}
else{
}
if (FName==null)
System.exit(1);
try{
if (FName.isEmpty())
throw new ArithmeticException("First name can not be empty!");
whetherContinue = false;
}catch (Exception ex)
{
JOptionPane.showMessageDialog(null,"The first name can not be empty! Please type again");
}
}while(whetherContinue); //First Name while