wood burning stoves 2.0*
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 8702
    
    6

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: 8764
    
    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: 36452
    
  15
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: 36452
    
  15
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 do I put an image on a canvas?
how to get Image from Canvas
putting screen output inside scroll bar
how to move a string
capture painted graphics outside canvas?? pls help