Friday, December 28, 2007

Jemmy library problem with multiscreen captures

There's a small, but annoying, problem in the way the screen is capture with Jemmy's captureScreen method, as far as I know it's only evident in multiscreen configurations.
The root of the problem is the use of Toolkit.getDefaultToolkit().getScreenSize() which is not multiscreen aware and thus virtual screen bounds are incorrect.

I've detected the problem writing some Java Swing GUI tests that capture the screen or part of it as they run in multiscreen configurations and got weird results. After some investigation and debugging I've found the use of Toolkit.getDefaultToolkit().getScreenSize() in PNGEncoder module.
Anyway, I'm providing a link to a patch using multiscreen aware display dimensions available from GraphicsConfiguration and GraphicsDevice.

The captures you may be obtaining are either incomplete or noisy like the examples shown here.
Showed before and after applying the patch.
Screen capture
Text field capture
Patch can be downloaded from

No comments: