Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to draw with mouse in SWT

 
Pranavan Kandasami
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I would appreciate if anybody could point me to some examples or tutorials on how to draw on a SWT surface (say a graphics context),just by moving the mouse on it(free drawing). I found examples on draw line , draw rectangle but i need to draw any free shape on the surface.

any help is appreciated.

Thanks
 
Campbell Ritchie
Sheriff
Posts: 51390
87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

There is an example in the Deitels' Java book where they append tiny circles to an array (maybe an ArrayList would have been better) using a mouseDragged() method of a MouseMotionListener. I have tried that, and it works; if you move the mouse fast the line breaks into a series of spots.

I don't know how to do that, but there are ways of using the mouse position as it is dragged to perform an XOR using a method in the java.awt.Graphics class.

Sorry I can't be more specific, but maybe somebody else will have a better idea.
I looked on Google: this looks promising.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic