Is that possible to grab pixels from AWT component?
-
12-12-2019 - |
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:
- Get AWT component bounds
- Make screenshot with specific bounds.
Solution
Seems like the only working solution is to:
- Find component bounds in screen coordinate system.
- 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