javaappletscreenshotawtrobot

Taking screenshot with Java applet using Java Robot class not working


I am using a Java applet to take a screenshot of the web browser, using Java's Robot class.

Robot objRobot = new Robot ();
BufferedImage objBufferedImage = objRobot.createScreenCapture(objRectArea); 

The thing works good in Windows system, taking screenshot. But in case of Mac OS X I get a blank image.

When I check the event viewer, I see the following error:

invalid context
invalid pixel format
CoreAnimation: rendering error 506

The problem is occurring for all the browsers Safari, Firefox and Chrome. My applet is a signed applet.

What might be the reason?

My machine configuration is as follows:

OS : MAC OS X
Version : 10.6.4

Solution

  • I've sent the error message invalid pixel format to google and received a long list of results (close to 10.000) - it looks as if the problem is not a Java problem but a configuration issue on your Mac.

    Try to change display resolutions and re-run your applet. Good chance, that the error is linked to some screen resolutions (external display?). Some suggestions on the web were to fully update you OSX.