Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Handling Child events in Parent?

 
Akshay Kumar
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

how to handle child events in parent when both having separately implemented listeners?

Problem 'm facing:
i've an Applet and i created two classes(each extends AWT Panel and implements ActionListener) as "Pan1" and "Pan2". Onloading of the applet, "Pan1" is instantiated and made visible after adding into applet. "Pan1" contains a button. Actually, when i click on this button "Pan2" should be created and made visible which contains some other controls.

here, how'll i listen for the events of "Pan1" in applet and to load "Pan2" into applet itself. Inturn both those panels implements listeners to act internally.

hope 'm clear. if possible, can come out with sample code. Or if there any other approach.
Thanks.
 
clio katz
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
seems several options are possible:

panel1 "show panel2" button
. implement actionlistener as anonymous inner class
. implement special actionListener class
. associate an AbstractAction-derived class
. etc

parent can also be the listener for this component...

possible panel2 display strategy
. if layout/screen real estate is fixed,
you could instantiate an invisible panel2,
and have the button trigger _setVisible



can you post some code?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic