Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Draw with GC on Canvas and redraw the canvas
Draw with GC on Canvas and redraw the canvas [message #460784] Wed, 07 September 2005 06:24 Go to next message
Eclipse UserFriend
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 #460786 is a reply to message #460784] Wed, 07 September 2005 06:46 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ssc.acentic.net

Nevermind, a simple canvas.update(); after the redraw, did the job.
Re: Draw with GC on Canvas and redraw the canvas [message #460806 is a reply to message #460786] Wed, 07 September 2005 13:16 Go to previous message
Eclipse UserFriend
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
Previous Topic:change font for all widgets in an application
Next Topic:how to re-set style of Text
Goto Forum:
  


Current Time: Wed Jul 17 12:19:43 GMT 2019

Powered by FUDForum. Page generated in 0.02094 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top