The callback is proper – there is no flaw in your code, besides you are using deprecated functions.
Consider using this:
try {
Rectangle screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
BufferedImage capture = new Robot().createScreenCapture(screenRect);
ImageIO.write(capture, "JPEG", new File("printed1.jpg"));
} catch (Exception e) {
e.printStackTrace();
}