hi, yes, this can be done. rewrite the paint(Graphics g) method of the component (eg. Canvas) you want to draw to. you can find some examples on the net eg. draw aplet it consist of the files: Dot Applet and Canvas this one is without comments....but you should understand it. k
or do you want to draw an image like jpg, gif... ?
[This message has been edited by karl koch (edited November 29, 2001).]
Originally posted by priya aravind: I am trying to write code to draw an image in an applet window. Is there any way to do it using the awt and graphics class? Thanks. Priya
Create an Image reference and a Graphics reference like so: Image buffer; Graphics bufferg; Then create objects like so: buffer = createImage (getSize ().width, getSize ().height); // or whatever size you want the image to be bufferg = buffer.getGraphics (); Then in your paint method, draw everything using the bufferg reference (which will draw everything on the image) and finally in your paint method, draw the image to the ImageObserver: g.drawImage (buffer, 0, 0, this); // this = ImageObserver reference Hope that's what you're looking for ------------------ Michael J Bruesch Codito, ergo sum... I code, therefore I am. My Java Games, I'm quite proud
Michael J Bruesch<br /><i>I code, therefore I am.</i>
Joined: Nov 28, 2001
Thanks Karl and Michael.The tips are very helpful.I wanted to create a paintbrush -like editor.