Re: Java/OOP Question/Problem
- From: DBloke <DBloke@xxxxxxxxxxx>
- Date: Thu, 07 Feb 2008 20:58:02 +0000
Eric Sosman wrote:
Your wife says "Honey, I want a Poodle, which, as youNot true whatever she asks for and I giver her she is never satisfied :)
know, is a specific kind of Dog." So you go to the pet
store and buy a Schnauzer, which is also a specific kind
of Dog. Will your wife be satisfied?
The method says "I want an ImageFrame, which, as you
know, is a specific kind of Frame." So you go to the window
store and buy a JFrame, which is also a specific kind of Frame.
Will the method be satisfied?
I am guessing not :)
"To achieve this ..." Well, it depends what you mean byPlease understand even if I gave my wife the damned poodle she would still not be satisfied :)
"this." If you mean "Make the method accept my JFrame even
though it's not an ImageFrame, as required," the answer is no:
You cannot do it. Your wife wants a Poodle and will not accept
a Schnauzer instead, even though both are Dogs.
She still wouldn't be satisfied with all or any of the above :)
But if you mean "Make the method accept my own extension
of ImageFrame," the answer is yes. Create your own BlokeFrame
class that extends ImageFrame, endow it with whatever methods
you like, and pass a BlokeFrame to the method. Since your
BlokeFrame *is* an ImageFrame, the method accepts it. Your
wife will be happy if you bring her a Miniature Poodle or a
Toy Poodle or a Standard Poodle; all are Poodles.
Hmmm this was as I feared. It would have been better if the method took an Interface or Frame reference, problem solved :), but this is not the case :( is there a way I can make a Frame look like a JFrame? I tried your way and it works as expected because of the is-a relationship, but it looks fugly compared to the other windows, even playing with the look-and-feel voodoo of AWT I want my new BlokeFrame to look like a nice Windows XP Frame :) like all the other frames :p.
Thanks for your help anyway
DB
.
- Follow-Ups:
- Re: Java/OOP Question/Problem
- From: Mark Space
- Re: Java/OOP Question/Problem
- From: Eric Sosman
- Re: Java/OOP Question/Problem
- From: Donkey Hot
- Re: Java/OOP Question/Problem
- References:
- Java/OOP Question/Problem
- From: DBloke
- Re: Java/OOP Question/Problem
- From: Eric Sosman
- Java/OOP Question/Problem
- Prev by Date: Re: Java/OOP Question/Problem
- Next by Date: Re: Java/OOP Question/Problem
- Previous by thread: Re: Java/OOP Question/Problem
- Next by thread: Re: Java/OOP Question/Problem
- Index(es):
Relevant Pages
|