Setup screen capture robot

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
main
Nic0Nic0Nii 3 years ago
parent e99eaa0f43
commit 84a3ce417c
  1. BIN
      ArcadeScreenshotHandler.jar
  2. 24
      src/sig/ArcadeScreenshotHandler.java

@ -1,9 +1,19 @@
package sig;
import java.io.IOException;
import java.nio.file.Path;
import java.awt.image.BufferedImage;
import java.awt.AWTException;
import java.awt.GraphicsEnvironment;
import javax.imageio.ImageIO;
import javax.swing.JFrame;
import java.awt.Robot;
import sig.engine.Panel;
public class ArcadeScreenshotHandler {
public static Robot r;
public static final String PROGRAM_NAME="Sig's Java Project Template";
public static void main(String[] args) {
JFrame f = new JFrame(PROGRAM_NAME);
@ -17,5 +27,19 @@ public class ArcadeScreenshotHandler {
f.setVisible(true);
p.render();
try {
r = new Robot();
BufferedImage img = CaptureScreen();
ImageIO.write(img,"png",Path.of("screenshot.png").toFile());
} catch (AWTException | IOException e) {
e.printStackTrace();
}
}
private static BufferedImage CaptureScreen() throws IOException {
BufferedImage screenshot = r.createScreenCapture(GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds());
//ImageIO.write(screenshot,"png",new File("screenshot.png"));
return screenshot;
}
}

Loading…
Cancel
Save