简体   繁体   中英

java:print out of Jframe

I want to take the print out of jFrame ,I can use printutility and all necessory for printing. Now my problem is that how to send the jFrame to printer for print out of jFrame?

Is it possible to take the print out of jFrame or any other solution?

You should take an image of the JFrame by painting the component to an image, and then send the image to a printer using the java.awt.print API.

public static BufferedImage takeScreenshot(Component comp) {
    BufferedImage image = new BufferedImage(comp.getWidth(), comp.getHeight(), BufferedImage.TYPE_INT_RGB);
    component.paint(image.getGraphics());
    return image;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM