Sharing Variables Among Multi-JFrame Environment?
I'm pretty new to Java and have been racking my brains these past few days trying to work out how to achieve this.
I'm am creating an application that stores information about users, to open the application you are first presented with a login screen (username and password). Upon correct entry of user and pass, you are taken to another window where information about the user can be viewed/edited. There is a button on the window that will open another window where yet more information can be viewed/edited. I am declaring each window as a new class and in a new .java source file for ease of maintainence etc. My question is, where should I store this arraylist of users so that all windows can access it knowing that each window is its own class? - Is there a standard way to do this for example?
My initial idea is to declare a runner class which initially opens the user and password window, but I've noticed that when a window opens, the runner class (instigating class) doesn't stop and wait until that window closes, nor have I seen how to send a message back to the runner class. In an ideal world I would have something like this:
Open User/Password window
Send message back to runner that user password correct
Open second window from runner
But how would I pass a message back from the user/password window that there has been a successful login, how also do I make the runner wait for that window to close to continue execution.
I'm sorry that at this stage this problem is rather theoretical and I can't show any specific code. I'd be very grateful of any help!