AWT Applet: Copying a screen area/portion
I am new to Java. And I have a question regarding copying a screen area to a memory. For example, I have an applet and drawn a rectangle on the applet. Inside the rectangle, I made some other shapes like circles, triangles and ovals. Would it be possible to copy the rectangle and all the shapes in it and paste the rectangle with all its shapes inside only after an event, for example a mouseClick event perhaps?
The short answer is Yes, it would be possible.
How to do it is another question.
The approach might be to create your own Graphics object and call the paint() method to have it draw in your Graphics context what it has previously drawn on the screen. And then create an image from that.
Just create a BufferedImage in the size you need and get its graphics context. Then pass that objet to your paint(Graphics g) method.
If you need to save the graphics to a file use the attatched code like:
// first get an output stream, and get an Image
Last edited by sjalle; 08-18-2005 at 04:32 AM.
Reason: uups, forgot the zip
Thanks for your replies guys. I'll try to implement your suggestions and post you for updates.
By Tataroz T. in forum Java
Last Post: 10-20-2005, 07:19 AM
Last Post: 07-12-2005, 11:49 AM
By Charlie Flynn in forum Java
Last Post: 08-23-2001, 12:01 PM
Last Post: 03-09-2001, 10:49 AM
By Rocco Balsamo in forum Java
Last Post: 07-27-2000, 01:50 PM
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center