File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes How to use Ploymorphism Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to use Ploymorphism" Watch "How to use Ploymorphism" New topic

How to use Ploymorphism

James Hambrick
Ranch Hand

Joined: Sep 04, 2004
Posts: 282

I guess this is a polymorphism question. In the Notebook class I am wanting to call the setFont method from the Page class. I can create a Page object but that object is only viable within the method I create it. Then in the Page class I am wanting to get the font of the text area that's created in the Notebook class.

Visit my blog!
Brad Dwan
Ranch Hand

Joined: Apr 22, 2010
Posts: 62
google gave me this:

what's wrong with page1 you declared at the top?

also I don't really think you need extend Page with Notebook. You Already have an object page1; you should be able to access all of Page -s methods with that.
so you could use:

I dunno, haven't tested it or anything, but the object is there and methods are public, so I can't see why it wouldn't work.

"It's about choosing your battles, not fighting somebody else's war"
I agree. Here's the link:
subject: How to use Ploymorphism
It's not a secret anymore!