• 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

Inheritance: How do I bypass the immediate ancestor?

 
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I just can't directly inherit EditCustomer from GenericForm because
I need to carry on forward some of the functionality of ViewCustomer.
But When I am doing the above, the hints will be "accumulated" twice
ending up with 4 hints. How can I call initComponents of GenericForm
directly from EditCustomer and bypass ViewCustomer's initComponents()?
Thanks
Jack
 
Saloon Keeper
Posts: 15524
364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why not:
When you override a method, you're stuck with it. You can not invoke a method of a grandparent, because it's overridden. That's kind of the definition of overriding.

P.S. @Override is with capital O.
 
Jacky Luk
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:Why not:



Hello Stephan,
The reason I couldn't do the way you described because
GenericForm's initComponents will do some processing with
the hints variable after someone
had added some strings into it.
Humm, I think that's why... may be some flaws
with my design.
Thanks
Jack
 
Stephan van Hulst
Saloon Keeper
Posts: 15524
364
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So split the initializing and the processing. Instances should never perform *any* work before being properly initialized.

Besides, superclasses should not need to know about what subclasses can do. Can you give us more detail about the purpose and working of the program?
 
Jacky Luk
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got it. What I am doing is to push some hints into the array,
and giving the user some hints which screen he/she is at the moment.
Thanks
Jack
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic