• Post Reply Bookmark Topic Watch Topic
  • New Topic

difficulty Using Canvas  RSS feed

 
singh sagar
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi evry1
i am creating a gui form(In NETBEANS) in which i am using a canvas.
now in my prog i have a Graphic2d object which contains a image.
How to add this image to canvas
Thanks
sagar
 
Norm Radder
Rancher
Posts: 1733
22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried overriding the paint() method of the Canvas class and using a Graphics draw...() method?
 
singh sagar
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for reply Norm Radder
Can you please explain more
 
Campbell Ritchie
Sheriff
Posts: 53779
128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may need to cast the Graphics object to Graphics2D before you can use it as Graphics2D.
 
Norm Radder
Rancher
Posts: 1733
22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use a search for paint() and drawImage(). I'm sure you'll get lots of code examples.
Or just override the paint() method and use the drawImage() method.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!