• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

call back

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I have 2 classes both inherites from javax.swing.JDialog. One calls a function in the other which then, after an awt event on the latter, calls back a function in the original.
If I make the initial calling class the parent and store its object in "parentFrame" member variable in the child class as in the child constructor (pls see below), I tried to call the parent's function from child by: parentFrame.a_function_in_parent() but got error. How can I call the parent function on the passing parent object without creating a new parent object? Thank you.

======================
public dlgChoose(javax.swing.JDialog parent,boolean modal) {
super (parent, modal);
parentFrame=parent;
initComponents ();
pack ();
}
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What error did you get?
Callbacks are not very OO though since it creates tight coupling between classes. Check out the Observer interface and the Observable object. Observer is also a Design Pattern discussed in the GoF book.
J.Lacar


[This message has been edited by JUNILU LACAR (edited March 06, 2001).]
 
tom nugent
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, Junilu. I will find the book. I've heard of 'callback' before, but I am not sure my reference is the same thing. I'll look into that, however.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic