April 28th, 2000, 03:30 AM
how can I draw in a offScreenImage and only then draw the offScreenImage in a pannel? And how can I obtain the offScreenImage?
|
Click to See Complete Forum and Search --> : offScreenImage April 28th, 2000, 03:30 AM how can I draw in a offScreenImage and only then draw the offScreenImage in a pannel? And how can I obtain the offScreenImage? lone_wolf_1985 April 28th, 2000, 05:21 PM 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. codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |