Determine which frame called windowActivated

B

Ben

I have a number of JFrames that call the same
windowActivated(WindowEvent we). How do I determine which frame caused
the event.

Thanks.

Ben.
 
G

Greg Webber

I haven't yet used windowActivated, but would this work?

Object src = we.getSource();

if(src == oneJFrame){
doStuff();
}else if(src == otherJFrame){
doSomethingElse();
}
I have a number of JFrames that call the same
windowActivated(WindowEvent we). How do I determine which frame caused
the event.

Thanks.

Ben.


--
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/IT/MU/O d-(++) s++: a-- C++++>$ UL++ P+ L+++>++++$ E- W+++>$ N++
o?>+ K+ w--- O?>O+ M?>+ V- PS@ PE+ Y+ PGP t+@ !5 X R+ tv++@ b++>+++ DI++
D+ G++ e- h! r- y-
------END GEEK CODE BLOCK------

http://friedoysters.hollosite.com/forum/index.php
 
T

Thomas Weidenfeller

Ben said:
I have a number of JFrames that call the same
windowActivated(WindowEvent we). How do I determine which frame caused
the event.

The best would be to provide them with separate event handlers. What is
the point in first merging something (the otherwise independent events),
and then trying to separate things once they are merged?

If you really want to mess with one handler only, evaluate the event's
source.

/Thomas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top