Skip to main content

closing jframe with button question.

1 reply [Last post]
kevinatgz
Offline
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.
walterln
Offline
Joined: 2007-04-17

See the [url=http://java.sun.com/docs/books/tutorial/uiswing/components/frame.html]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.