diff --git a/JavaProjectTemplate.jar b/ArcadeScreenshotHandler.jar similarity index 74% rename from JavaProjectTemplate.jar rename to ArcadeScreenshotHandler.jar index 94a1432..0e95ea7 100644 Binary files a/JavaProjectTemplate.jar and b/ArcadeScreenshotHandler.jar differ diff --git a/src/sig/ArcadeScreenshotHandler.java b/src/sig/ArcadeScreenshotHandler.java index 79c4807..1493ec3 100644 --- a/src/sig/ArcadeScreenshotHandler.java +++ b/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; } }