|
-
Jul 21st, 2005, 09:00 AM
#1
Thread Starter
Addicted Member
abstract method
I found that abstract method can't be implemented in the same class it defined.
But I see in java.awt.Graphics the following functions
fillOval....
-
Jul 21st, 2005, 11:10 AM
#2
Frenzied Member
Re: abstract method
Abstract classes CAN and most often do have concrete methods like that. Just because it's an abstract class doesn't mean it has to have only abstract methods.
-
Jul 21st, 2005, 12:11 PM
#3
Re: abstract method
I don't get the question here.
Yes Graphics is an abstract class, and fillOval is an abstaract method. So you can not make an instance of the Graphics file your self. But widgets can make it for you, like in the paint method.
- ØØ -
-
Jul 21st, 2005, 04:36 PM
#4
Frenzied Member
Re: abstract method
Hmm, so fillOval() IS an abstract method...That's confusing to me. Somewhere along the line this method is made concrete, and is given the code to perform it's operation, but where? It's not in the Graphics class? And you surely aren't required to come up with your own implementation.
-
Jul 22nd, 2005, 02:25 AM
#5
Re: abstract method
The graphics in Java and it events is the two things that bugs me the most except the speed with Java. I am not sure if it is me never taking the time to understand it, or if it is just very weird.
I guess there is some casting or some trick there that I have never looked into. But at least you can't make your own instance of the graphics object. At least not straight forward.
[Edit] As a wild guess without looking into it any furuther, I guess they do something like this. Lets say A is a base class, and B inheriths from A. Then they do something like:
A g = new B();
and then send you g. That is a pointer of type a (or a graphics object) but actualy is an object furuther down the hierarchy.
- ØØ -
Last edited by NoteMe; Jul 22nd, 2005 at 02:34 AM.
-
Jul 22nd, 2005, 07:31 AM
#6
Dazed Member
Re: abstract method
You can always grab a graphics contecxt via getGraphics() if you want. Pretty sure it's defined in java.awt.Component
-
Jul 22nd, 2005, 07:38 AM
#7
Re: abstract method
The paint() method gives you a Graphics reference, but the actual type is probably com.sun.awt.graphics.Graphics or whatever - the thing is, you just don't care as long as it works.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jul 25th, 2005, 01:08 AM
#8
Thread Starter
Addicted Member
Re: abstract method
I see java.awt.Graphics only extends Java.lang.Object.
And it is defined there procedures like
public abstract void fillOval()
then where are the implements of the procedures?
-
Aug 15th, 2005, 03:00 PM
#9
Re: abstract method
In classes you'll never know about. I believe the Sun JRE implements them in, for example, com.sun.awt.win32.Graphics2d. The Kaffee project elsewhere, as does the GNU Classpath project. But that's not your concern. Your concern is that, upon calling Component.getGraphics(), you receive an instance of a subclass of Graphics, which you can do stuff with.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|