Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

do something when other frame close

 
Edward Fernando
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 48944
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5126
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic