a simple question about "Graphics" and "setFont()"
Posted on 2001-06-17
I have a question to ask:
many times we can see the following method in a class which has some stuff to do with panel:
public void paintComponent(Graphics g)
Font f = new Font("SansSerif", Font.BOLD, 10);
so,my questions are:
1)it looks like i don't have to explicitly pass a parameter,
which is of type "Graphics", why? eg, i can use "repaint()" somewhere in this class, and the panel will be repainted. and i even don't have to put it like this:
Graphics xyz = new Graphics();
why is that?
2)I had a look at API and the method "setFont()" is an abstract
method. usually we re-define an abstract method in a class inheriting that abstract class, right? but as in the above example, it was just:
do some stuff;
and everything's going fine. anyone can explain it to me?
Thanks a lot for your help!