i continue to spit out small useful stuff that might interest someone. again, nothing fancy.
i’m getting lots of useful stuff in my Tools class now… might release a lib some day.
public static void takeScreenShot(String filename, Component con) {
try {
Robot r = new Robot();
Rectangle rect = new Rectangle(con.getLocationOnScreen().x, con.getLocationOnScreen().y, con.getWidth(), con.getHeight());
//BufferedImage image = r.createScreenCapture(rect);
BufferedImage image = (BufferedImage) con.createImage(con.getWidth(), con.getHeight());
con.paint(image.getGraphics());
int i = 1;
File f = new File(filename + i + ".jpg");
while (f.exists()) {
i++;
f = new File(filename + i + ".jpg");
}
ImageIO.write(image, "jpg", f);
}
catch (AWTException e1) {}
catch (IOException e2) {}
}
EDIT: changed the naming a little