For Programmers: Free Programming Magazines  


Home > Archive > Java Help > June 2005 > paint() being recalled ALOT









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author paint() being recalled ALOT
merjazz89@hotmail.com

2005-06-01, 3:58 am

i have seperate methods like :


public void drawLogo ()
{

Graphics g = getGraphics ();
g.drawImage (logo, 0, 0, this); //logo is already been
initialized
}

i think that whenever you call g.drawImage is repaints or call g.--
it calls the repaint() method ...is this true and how do i go about
changing this because it calls the repaint() method so often that all i
see if flickering and no images

majiedb@gmail.com

2005-06-01, 9:04 am

repaint is the most complicated of the methods because it is overridden
to take a differing number of parameters. If no parameters are given it
just called the update method which then calls paint. There are another
three versions which allow a time and specific co-ordinates to be
given. For example:

repaint (1000); // repaint in 1000 milliseconds

repaint (10, 20, 30, 40); // repaint the area: x = 10, y = 20, width =
30, height = 40

repaint (1000, 10, 20, 30, 40); // a combination of the two above

better make it as a thread and kill it !

merjazz89@hotmail.com wrote:
> i have seperate methods like :
>
>
> public void drawLogo ()
> {
>
> Graphics g = getGraphics ();
> g.drawImage (logo, 0, 0, this); //logo is already been
> initialized
> }
>
> i think that whenever you call g.drawImage is repaints or call g.--
> it calls the repaint() method ...is this true and how do i go about
> changing this because it calls the repaint() method so often that all i
> see if flickering and no images


majiedb@gmail.com

2005-06-01, 9:04 am

plz go through this link !
http://www.devarticles.com/c/a/Java/Swing-Animation/1/

Mark Haase

2005-06-01, 4:01 pm

I think the OP doesn't understand the paint() framework. You should not
be doing any drawing except when the applet is asked to repaint. Ie. you
should only be doing drawing in the paint() method...and if you were,
you'd already have a Graphics g object.

If you are doing an animation or something and you want to invalidate
the drawing canvas, you call repaint(..) in one of its forms below, and
Java responds by eventually calling paint() on your applet (among other
things.)


In article <1117618173.249887.311810@o13g2000cwo.googlegroups.com>,
majiedb@gmail.com wrote:
[color=darkred]
> repaint is the most complicated of the methods because it is overridden
> to take a differing number of parameters. If no parameters are given it
> just called the update method which then calls paint. There are another
> three versions which allow a time and specific co-ordinates to be
> given. For example:
>
> repaint (1000); // repaint in 1000 milliseconds
>
> repaint (10, 20, 30, 40); // repaint the area: x = 10, y = 20, width =
> 30, height = 40
>
> repaint (1000, 10, 20, 30, 40); // a combination of the two above
>
> better make it as a thread and kill it !
>
> merjazz89@hotmail.com wrote:

--
|\/| /| |2 |<
mehaase(at)sas(dot)upenn(dot)edu
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com