aspose file tools*
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
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "do something when other frame close" Watch "do something when other frame close" New topic
Author

do something when other frame close

Edward Fernando
Greenhorn

Joined: Feb 14, 2012
Posts: 4
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
Sheriff

Joined: Oct 13, 2005
Posts: 36520
    
  16
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
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: do something when other frame close
 
Similar Threads
Java Compiler
Thread - Wait() and Notify();
Scope and classes/methods
Q about UML Distilled: transient relationship?
Need Help! How can I......