Why are my JFrames closing?

I'm trying to create my own instant messenger and have come across a problem. I have a log in form, when the user enters their name. Once they click 'Log In', another window opens displaying the users that are currently online. My problem arises when I want to close the log in form. When I close this the other window that displays the online users also closes. Does anyone know why this happens??

Why not you try DISPOSE_ON_CLOSE or HIDE_ON_CLOSE because EXIT_ON_CLOSE calls Syste.exit(0) and exits the whole application. Dispose_on_close will only close the whole program when there are no active threads running and Hide_on_close will just hide your log-in window. Like what pete stein said why not try JDialog, its more relevant for the current situation.