question on applet
paint(Graphics g)
{
repaint();
g.drawstring("Inside Apple");
}
When i wrote my applet i called the repaint from a separate thread.Then i tried calling repaint from within paint just to see the outcome.From what i have read from the tutorials repaint calls paint().With regard to this i had expected the "Inside Applet" not to get printed as it encounters the repaint before the drawstring.Contrary to my expectations the string "Inside Applet gets printed".Shouldnt this code be engaged in calling itself infinitely without touching drawstring because paint is called evertime it encounters drawstring?
# 1
If this component is a lightweight component, this method causes a call to this component's paint method as soon as possible. Otherwise, this method causes a call to this component's update method as soon as possible.
AFAIK, Applet is AWT and thus not a lightweight component. Thus it depends on what update() does in your case. This question could have been asked in a more appropriate forum with experts on that topic, though.
by the way, recursive method calls won't go endlessly. In fact, they die very quickly with a stack overflow.
# 2
> If this component is a lightweight component, this
> method causes a call to this component's paint method
> as soon as possible. Otherwise, this method causes a
> call to this component's update method as soon as
> possible.
>
> AFAIK, Applet is AWT and thus not a lightweight
> component. Thus it depends on what update() does in
> your case.
Thanks CCnet.I will check it out
>This question could have been asked in a
> more appropriate forum with experts on that topic,
> though.
This forum has some of the biggest brains i have seen
> by the way, recursive method calls won't go
> endlessly. In fact, they die very quickly with a
> stack overflow.
Yes i am very much aware of that.I mentioned endlessly because i didint want someone to come up with a arguement sying that "Inside Applet" is getting printed because of stack overflow.
# 3
> Shouldnt this code be
> engaged in calling itself infinitely without touching
> drawstring because paint is called evertime it
> encounters drawstring?
No! repaint() adds an event to the event queue and does not call paint() directly. One should almost never call repaint() within a paint() method since it may create an infinite loop (not an infinite recursion).
# 4
>One should almost
> never call repaint() within a paint() method since it
> may create an infinite loop (not an infinite
> recursion).
Yes infact i called it from another thread to create a scrolling effect.Can see it here-"http://www.geocities.com/scw_0611/special.html"
Just thought of giving this a shot to see its effect.Incase you are reading this daffy i would like to thank you for actuating me to learn html.Though i know just the basics(very basic infact),i will get through the rest and live upto those words of encouragement you heaped on me.I dont have cash to get my own domain.Thanks for the help sabre and CCnet