here is the edited code with specified method.
String value = obj.validateTextFields(txtFields);
public String validateTextFields(JTextField[] txtField){
String res = "";
for(JTextField txtFields : txtField) {
if(txtFields.getText().equals("") ) {
JOptionPane.showMessageDialog(null, txtFields.getName() +" is empty!");
res +=txtFields.getName()+",";
}
}
return res;
value is the names of text fields so how to get the text field by this name.