A button in my app gets all the text you enter in 8 text fields and sends it to a table. I need code so that you need to fill in ALL fields before you can send the info. How do
You can check, if a field is empty by getting the text length and comparing it to zero.
If you don't want to check every text field in one single if-statement, you could check them separately and return, if one field has an invalid value.
if (jTextField1.getText().length() == 0)
{
//Tell the user, that the first field has to be filled in.
return;
}
if (jTextField2.getText().length() == 0)
{
//Tell the user, that the second field has to be filled in.
return;
}
//...
Otherwise, you could check them all in one if-statement:
if (jTextField1.getText().length() != 0
&& jTextField2.getText().length() != 0
&& ...)
{
//Fill in the table
}
else
{
//Tell the user, that the all fields have to be filled in.
}