Question

I know that it is possible to capture lightweight Swing component picture by calling paint(Graphics g) method on the BufferedImage.getGraphics() instance. Like here: Swing: Obtain Image of JFrame

Is it possible to grab AWT component's contents as an Image?

So far, I think of java.awt.Robot solution only:

  1. Get AWT component bounds
  2. Make screenshot with specific bounds.
Was it helpful?

Solution

Seems like the only working solution is to:

  1. Find component bounds in screen coordinate system.
  2. Use java.awt.Robot class to create screen capture of the area, which corresponds to the component.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top