Hello channi3 and welcome to the forums.

Take a look at this code example and compile it.

There is a main JFrame with a button on it. When this button is clicked, JFrame1 closes and opens...