// TODO add your handling code here:
try
{
BufferedImage buffy = new BufferedImage(this.jTable1.getWidth(),this.jTable1.getHeight(),java.awt.image.BufferedImage.TYPE_INT_RGB);
Graphics g = buffy.getGraphics();
this.jTable1.paint(g);
String path=System.getProperty("user.dir");
path+="\\1.png";
OutputStream out=new FileOutputStream(path);
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
JPEGEncodeParam param =encoder.getDefaultJPEGEncodeParam(buffy);
encoder.getDefaultJPEGEncodeParam(buffy);
param.setQuality(1.0f, false);
encoder.setJPEGEncodeParam(param);
encoder.encode(buffy);
}catch(Exception e)
{
e.printStackTrace();
} |