I am a web app programmer (mostly PHP/JavaScript/Ajax etc).
There is this payroll appplication that I want to code in java. I needed to know where I could find tutorials on how to do basic validation in java e.g. checking if a textfield is null, making sure only integers are allowed etc.
I have this basic program that runs and created a jFrame form:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
double num1, num2, result;
num1 = Double.parseDouble(jTextField1.getText());
num2 = Double.parseDouble(jTextField2.getText());
result = num1 + num2;
jLabel4.setText(String.valueOf(result));
}
How can I for instance get to validate that jTextField’s 1 and 2 are not left blank. i.e., to return an error box that lets a user know that both fields cannot be left blank?
I was trying this as a tester:
if(num1 == 0 && num2 == 0)
{
JOptionPane.showMessageDialog(null, "You must fill in all fields");
}
But this doesnt work at all
If it belongs to swing then check
or
Also read some tutorial on swing components.