I’m learning swing and I’ve created a simple form:

I’ve implemented on pressing submit button it checks whether all fields are not empty and shows message “Please fill in all the fields” if any field is empty, but I don’t know how to return to the form when you press “ok” if any field is empty. Now I’m using “System.exit(0);” but that’s not what I need. Thanks.

if (getTxt.trim().equals("") || getTxt2.trim().equals("") || getTxt3.trim().equals("") || getTxt4.trim().equals("") || getTxt5.trim().equals("")) {
JOptionPane.showMessageDialog(null,"Please fill in all the fields!!");
System.exit(0);
}
Assuming you are writing this code in onClick of Submit button.If so then you can return instead of exit. if you don’t have more code in the method then just remove System.exit(0);