/** * Paints this panel to fit the specified image. * @param image the image. */ public void paintToImage(BufferedImage image) { Graphics2D g2d = image.createGraphics(); // Set panel properties. g2d.setColor(getBackground()); g2d.fillRect(0,0,image.getWidth(),image.getHeight()); g2d.setColor(getForeground()); g2d.setFont(getFont()); // Turn on anti-aliasing. g2d.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // Paint this panel to fit the image. paintToRect(g2d,0,0,image.getWidth(),image.getHeight()); g2d.dispose(); }