Getting and Image from a Component
Hey, this is the problem:
Supose you have done a random paint on your component, for example you are drawing a fractal that evolves with respect to many parameters like a response to an internet service. How can I get this image. I know how to encode an image for save it, I just want to know how get an already drawed one.
# 1
It could be as simple as this:
BufferedImage image = new BufferedImage(comp.getWidth(), comp.getHeight(), BufferedImage.TYPE_INT_RGB);
Graphics2D g = image.createGraphics();
comp.paint(g);
g.dispose();
ImageIO.write(image, "jpeg", new File("temp.jpeg"));
# 3
Ehh... the problem with component.paint(my_g) is that the component don't have the information for redraw it, because the image was generated randomly. With Alt+PrintScreen is a good aproach but I prefer doi it programatically, I need it.
However, thank you so much, I will add 7 stars to this post :D
Thanks!!!!!!!!
# 4
> don't have the information for redraw it, because the image was generated randomlyThen your component is designed incorrectly. If is data is generated randomly, your component could add that data to its state show that it could redraw itself.