Galera tenho a seguinte classe que printa a tela do meu pc quando executo shift + f6 porém gostaria de ter um botão onde clico e ele printa a tela na qual ele está alguém pode me ajudar? a seguir está o código da classe que faz o print…
package visão;
import java.awt.AWTException;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
/**
*
* @author Mattheus
*/
public class Capture {
private static Rectangle Rectangle;
public static void main(String []args ) throws AWTException, IOException {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
Robot robot = new Robot();
Dimension a = Toolkit.getDefaultToolkit().getScreenSize();
Rectangle = new Rectangle(a);
BufferedImage img = robot.createScreenCapture(Rectangle);
ImageIO.write(img,"jpg",new File("c:/z/1.jpg"));
ImageIO.write(img,"bmp",new File("c:/z/1.bmp"));
ImageIO.write(img,"png",new File("c:/z/1.png"));
}
}