Skip to main content

closing jframe with button question.

1 reply [Last post]
Joined: 2009-04-30

there is a JFrame A with a button on it, after click A the JFrame B will be open
how to close the JFrame B when I click a "close" button on B and then show the JFrame A?
Thanks in advance.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2007-04-17

See the [url=]tutorial[/url], especially the section 'Responding to Window-Closing Events'.

For reshowning frame, it depends. Do you hide frame A when showing frame B?
If B has a reference to A, just call a.setVisible(true).
Otherwise have frameA add a WindowListener to B to reshown itself when B closes.