I am making a Java gui project and it consists of two frames.
The problem is that when I call the secondframe from the firstframe, I have set it such that the firstframe visibility is set to false. The problem is how do I make the firstframe visible again by using a button from the second frame.
should i ditch this method and create a new jpanel instead??? Does jpanel have similar capabilities as jframe?
Consider using
CardLayout
. This way you can switch via multiple UIs without needing another frame. Here's how to use it.Edit: As Guillaume posted in his comment, this answer from Andrew also covers how to use the layout.
Edit2:
As you requested a little more information about my latest post, here's how such a class may look like:
This way you would only instantiate every
JFrame
once, but you could always access them via your manager class. What you do with them after that is your decision.I also just made it thread-safe, which is crucial for singletons.