Search code examples
javaswingjframeinstances

How to open a JFrame that was previously hidden from another class?


I have 2 frames and in the first one, I press a button to go to the other and then I hide the frame with:

frame1.this.hide();    

How can I set that frame visible without creating a new one?

I know that I can make an instance to open a new frame1 from the frame2 but I want to "unhide" the first one when I press a button in the second JFrame.

Hope anybody know how to do this?


Solution

  • what you have to do is when creating Frame 2 . you have to pass same reference of Frame 1 then inside frame 2 you can change the viability of Frame 1