CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Help

  1. #1
    Join Date
    Jun 1999
    Posts
    13

    Help

    Hi,

    How to capture the screen from a Java application?
    Thanx in advance.

    Moor
    [email protected]


  2. #2
    Join Date
    May 1999
    Location
    Pune, MH, India.
    Posts
    453

    Re: Help

    I don't think there is direct way u can capture screen using Java.

    It might be possible using Java Native Interface.

    - UnicMan
    http://members.tripod.com/unicman

  3. #3
    Join Date
    Aug 1999
    Posts
    10

    Re: Help

    There is a way to "print" the screen. This may help. I have only done it with a Frame, and i'm not sure if it will work with an Applet but it may give you an idea. Create a graphics object that you can use. You can do this by obtaining it from the paint() method or:
    Image image = createImage(width, height); // you'll need to decide the appropriate dimensions
    Graphics g = image.getGraphics();


    This will get you a graphics object you can use. If you're doing this in a Frame, you have to put the above code after the setVisible(true); line, otherwise the graphics will be null. Then you can paint anything you want on to this graphics object. In your case, you want to paint the application. So you need something that extends the Component class, like a Frame or something. All you need to do, is take the object(lets say a Frame in this case) and call the printAll() method and pass the Graphics object you created:
    Component c = this; // Make a component object out of the Frame
    c.printAll(g);



    This will print the Parent component and all of its subcomponents. Now that you have the Graphics object with your app on it, you can do what you will with it. This is similar to what i used for an app to be able to print a screen shot of it. If you need to make a .gif or .jpeg, that's another issue, and you'll have to find out how to turn the object into a file of that type for extenal viewing.
    Hope this helps.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured