Draw with GC on Canvas and redraw the canvas [message #460784] |
Wed, 07 September 2005 06:24 |
Eclipse User |
|
|
|
Originally posted by: ssc.acentic.net
Hi
I have a little problem with GC. I like to draw something, in this case
on a canvas. Drawing is not the problem, but redraw the canvas and drawing
something in the same method seems to be.
canvas.redraw();
gc = new GC(canvas);
gc.setAlpha(40);
gc.setBackground(display.getSystemColor(SWT.COLOR_GREEN));
gc.fillRectangle(0, 0, 100, 20);
gc.dispose();
With this code, I do not see the green rectangle. If I remove the redraw
command, it works, but it will paint over and over again.
Any idea how to avoid this ?
-Sebastian
|
|
|
|
Re: Draw with GC on Canvas and redraw the canvas [message #460806 is a reply to message #460786] |
Wed, 07 September 2005 13:16 |
Eclipse User |
|
|
|
Originally posted by: richkulp.us.NO_SPAM.ibm.com
You really should not be doing drawing outside of a PaintListener
callback. That is because there are many reasons why your Canvas could
be redrawn. Such as someone covered it up and then reexposed it. In that
case your extra drawing will disappear. Instead you should add a
PaintListener and use the GC passed into the PaintListener to do your
extra painting. That way it will show up no matter why the Canvas was
redrawn.
Sebastian Scholz wrote:
> Nevermind, a simple canvas.update(); after the redraw, did the job.
--
Thanks,
Rich Kulp
|
|
|
Powered by
FUDForum. Page generated in 0.03235 seconds