I'm fairly new to Java and GUIs and am trying to work on a side project. I'm finding that as I continue to make more and more GUIs within eachother, I am continuously needing to access information that originated in the first GUI, from within deeper GUIs.
For example, I have a variable in the first GUI, after a user clicks on four or five sequential buttons (thus 4 or 5 GUIs later), I need to access said information.
So far I've just been passing this information into the initialization of the GUIs via their constructors, thus accessing it from there. Is this the "proper" way of accessing said information? Or is there a convention/more efficient way of doing so?
Within the first (main) GUI, I have a variable holding a username. After the user clicks on "Login" - then "Account Settings" then "Profile" - from within the "Profile" GUI, I need to access the variable "userName" originating in the main GUI. Currently I just pass this information into the constructors leading to Profile - is there a better way to do this? Perhaps a way to centralize all this information?