AWT Applet: Copying a screen area/portion


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: AWT Applet: Copying a screen area/portion

  1. #1
    Join Date
    Aug 2005
    Posts
    2

    Question AWT Applet: Copying a screen area/portion

    Hello Everyone,

    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?

    Thanks.
    gil

  2. #2
    Join Date
    Jul 2005
    Location
    SW MO, USA
    Posts
    299
    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.

  3. #3
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560

    Many ways..

    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:

    Code:
    OutputStream out=null;
    Image image=null;
    
    // first get an output stream, and get an Image
    .
    .
    GifOutputStream.writeGIF(out,image);
    Attached Files Attached Files
    Last edited by sjalle; 08-18-2005 at 04:32 AM. Reason: uups, forgot the zip
    eschew obfuscation

  4. #4
    Join Date
    Aug 2005
    Posts
    2
    Thanks for your replies guys. I'll try to implement your suggestions and post you for updates.
    Thanks!

Similar Threads

  1. JavaMail applet problem
    By Tataroz T. in forum Java
    Replies: 1
    Last Post: 10-20-2005, 07:19 AM
  2. function for copying a screen region
    By Amrita in forum C++
    Replies: 2
    Last Post: 07-12-2005, 11:49 AM
  3. Replies: 3
    Last Post: 08-23-2001, 12:01 PM
  4. Applet Refresh
    By Dan in forum Java
    Replies: 2
    Last Post: 03-09-2001, 10:49 AM
  5. Applet Loader Splash Screen
    By Rocco Balsamo in forum Java
    Replies: 1
    Last Post: 07-27-2000, 01:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center