0

I want to create an application in a swing to which validation of user is performed by providing login form. My application program name is application.java I developed a Login form(Loginform.java) using swings . It worked successfully . when i access it using my application.java class It performs validation and then complete application is terminate. please give me suggestion by which validation is done and My application program not to be teminated.

2 Answers2

3

I suppose if you use Loginform.java as JFrame, bear in mind that on close login you kill all your program. Implement Login form as Dialog and all will work as you expected.

Just initiate your main frame application.java (set class name with uppercase), Show Login JDialog Box and on success set main JFrame visible.

JDialog examples: link

How to create Login Dialog box see here

enter image description here

Maxim Shoustin
  • 77,483
  • 27
  • 203
  • 225
3

This is most likely due to the fact in your LoginForm.java you have called setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); which will cause your Event Dispatch Thread and Initial thread to be killed.

Rather use something like:

setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

On a side note, it is not considered good practice to use multiple JFrames:

You can have a look at the CardLayout which will allow you to flip between JPanels on a single JFrame. Or use a JDialog as your login screen which will initiate the main JFrame

Community
  • 1
  • 1
David Kroukamp
  • 36,155
  • 13
  • 81
  • 138