|
-
April 28th, 2000, 03:30 AM
#1
offScreenImage
how can I draw in a offScreenImage and only then draw the offScreenImage in a pannel? And how can I obtain the offScreenImage?
-
April 28th, 2000, 05:21 PM
#2
Re: offScreenImage
To draw onto an off screen image, you invoke the method "getGraphics()" on the image. Then you can paint over the image using the graphics object as you normally would in the paint method.
Here's an example:
off_screen_image.getGraphics().drawString("This is a string.", 25, 25);
This draws the string "This is a string." onto the image at the coordinates 25, 25. You can also just store the graphics object by using off_screen_image.getGraphics() instead.
If you want to draw the image in a panel, you must extend java.awt.Panel. Then in the paint method, you can draw the off screen image.
To obtain the off screen image, use the java.awt.Component method "createImage(int, int)" to create an image of the specified width and height.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|