This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Canvas Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Canvas" Watch "Canvas" New topic
Author

Canvas

colton peterson
Ranch Hand

Joined: Nov 18, 2007
Posts: 97

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();


www.mormon.org
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8842
    
    7

Look at the Java API documentation for Canvas and search for "Graphics".


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Bert Bates
author
Sheriff

Joined: Oct 14, 2002
Posts: 8805
    
    5
let's slide this over to a more graphically oriented forum...


Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38062
    
  22
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.
colton peterson
Ranch Hand

Joined: Nov 18, 2007
Posts: 97

thanks
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38062
    
  22
Originally posted by colton peterson:
thanks
You're welcome
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Canvas
 
Similar Threads
how to get Image from Canvas
putting screen output inside scroll bar
capture painted graphics outside canvas?? pls help
how to move a string
How do I put an image on a canvas?