/** * Method will save the JComponent as an image. The formats are PNG, and * TIFF. * * @param filename * name of the file to store the image into * @param type * of the image to be stored. Can be one of {@value #PNG} for PNG * or {@value #TIFF} for TIFF * @param component * to draw the image on */ public void saveJComponent(String filename, int type, JComponent component) { Dimension size = component.getSize(); BufferedImage image = new BufferedImage(size.width, size.height, BufferedImage.TYPE_BYTE_INDEXED); Graphics2D grp = image.createGraphics(); component.paint(grp); if (type == PNG) { filename += PNG_EXTENSION; this.savePNGWithBatik(filename, image); } else if (type == TIFF) { filename = filename + TIFF_EXTENSION; this.saveTIFFWithBatik(filename, image); } }