public void OnSaveJPG() {
Rectangle rect = getBounds();
BufferedImage image =
(BufferedImage)createImage(rect.width, rect.height);
Graphics g = image.getGraphics();
paint(g);
g.dispose();
try {
FileOutputStream fileStream =
new FileOutputStream("E:\\Test.jpg?http://www.xvna.com");
JPEGImageEncoder encoder =
JPEGCodec.createJPEGEncoder(fileStream);
encoder.encode(image);
fileStream.close();
} catch (Exception e) {
System.out.println("Error saving JPEG file!");
}
}