If you need to save a Java component and what might be placed on it as an image, the following JPanel will allow that. The source is HERE

import javax.swing.JPanel;
import javax.imageio.ImageIO;
import java.io.File;
import java.io.IOException;
import java.awt.image.BufferedImage;
import java.awt.Graphics;
import java.awt.Rectangle;


public class ImageSaverPanel extends JPanel {
    public void save(String imageFile) {
        Rectangle r = getBounds();

        try {
            BufferedImage i = new BufferedImage(r.width, r.height,
                    BufferedImage.TYPE_INT_RGB);
            Graphics g = i.getGraphics();
            paint(g);
            ImageIO.write(i, "png", new File(imageFile));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}