Win a copy of Raising Young Coders: A Parent’s Guide to Teaching Programming at Home this week in the General Computing forum!
Forums Login/signup

Canvas

+Pie Number of slices to send: Send
how do you use Canvas. I understand that you need a Graphics object, but I'm not sure how to get one of those as I am pretty sure you can't say

Graphics g = new Graphics();
+Pie Number of slices to send: Send
Look at the Java API documentation for Canvas and search for "Graphics".
+Pie Number of slices to send: Send
let's slide this over to a more graphically oriented forum...
+Pie Number of slices to send: Send
I thought most people used JPanel for painting on nowadays.

Go and look through the API for Canvas and you find it has a paint method.
You will have to extend Canvas and override the paint method, something like this:-At least I think you do; I have never tried. The bit about super.paint clears the Canvas so you start on a blank screen.
+Pie Number of slices to send: Send
thanks
+Pie Number of slices to send: Send
 

Originally posted by colton peterson:
thanks

You're welcome

reply
reply
This thread has been viewed 1222 times.
Similar Threads
how to get Image from Canvas
How do I put an image on a canvas?
how to move a string
capture painted graphics outside canvas?? pls help
putting screen output inside scroll bar
More...

All times above are in ranch (not your local) time.
The current ranch time is
Jun 27, 2025 09:07:22.