jQuery in Action, 3rd edition
The moose likes Swing / AWT / SWT and the fly likes do something when other frame close Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "do something when other frame close" Watch "do something when other frame close" New topic

do something when other frame close

Edward Fernando

Joined: Feb 14, 2012
Posts: 5
hello, i need help in java about swing...

i have 2 class which have frame in it, let say classA and classB
is there any way so that when frame in classB closed i do something in classA
for example when classB closed a textArea in classA will write a text.

i've done this in classA

but there is nothing happen....please help me...
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 44610
Welcome to the Ranch

Why have you got two frames? Why not use a dialog for the second window?
You can add a WindowListener which fires when a frame closes.
[edit]I see you already have such a listener[/edit]
Darryl Burke

Joined: May 03, 2008
Posts: 5048

but there is nothing happen....please help me...

Impossible to help without seeing all the relevant code. To get better help sooner, post a SSCCE (Short, Self Contained, Compilable and Executable) example that demonstrates the problem.

And I second Campbell's advice: most applications are best designed with only one JFrame, and other UIs as JDialogs, commonly modal.

edit Your initComponents() call implies that you are using a visual designer -- definitely not a beginners' tool. Is that guess correct?

luck, db
There are no new questions, but there may be new answers.
I agree. Here's the link: http://aspose.com/file-tools
subject: do something when other frame close
It's not a secret anymore!