Input form in Java

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);
}

Answers


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);

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!!");
  return;
}

Need Your Help

Visual Stuidos Formview with HTML5 controls

c# asp.net html5 visual-studio-2010

Is it possible to put HTML5 controls inside a FormView Control in visual studios.

Restore nuget package Jenkins

jenkins msbuild

When I tried to use Jenkins as our CI environment to build ASP.NET MVC5 project, I set up to use MSBuild.exe to build project.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.