Last active
February 4, 2016 05:15
-
-
Save arumoy/5f592de94fb23d1ef9e5 to your computer and use it in GitHub Desktop.
Take screenshot of a particular JFrame in Swing(Java)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void scrshtActionPerformed() { | |
/** | |
* this gist outline the process to grab the screenshot of a particular | |
* JFrame in Swing from which the method is invoked | |
* | |
* "this" is the particualr frame here | |
* */ | |
BufferedImage screenshotImage = new BufferedImage( | |
this.getBounds().width, this.getBounds().height, | |
BufferedImage.TYPE_INT_RGB); | |
this.paint(screenshotImage.getGraphics()); | |
try { | |
ImageIO.write(screenshotImage, "png", new File("screenShot.png" )); | |
} catch (IOException ex) { | |
System.err.println("ImageIsuues"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment