public class ScreenshotTaker extends Object
Components.| Constructor and Description |
|---|
ScreenshotTaker()
Creates a new
ScreenshotTaker. |
| Modifier and Type | Method and Description |
|---|---|
void |
saveComponentAsPng(Component c,
String imageFilePath)
Takes a screenshot of the given AWT or Swing
Component and saves it as a PNG file. |
void |
saveDesktopAsPng(String imageFilePath)
Takes a screenshot of the desktop and saves it as a PNG file.
|
void |
saveImage(BufferedImage image,
String filePath)
Saves the given image as a PNG file.
|
BufferedImage |
takeDesktopScreenshot()
Takes a screenshot of the desktop.
|
BufferedImage |
takeScreenshotOf(Component c)
Takes a screenshot of the given AWT or Swing
Component. |
public ScreenshotTaker()
ScreenshotTaker.ImageException - if an AWT Robot (the responsible for taking screenshots) cannot be instantiated.public void saveDesktopAsPng(String imageFilePath)
imageFilePath - the path of the file to save the screenshot to.NullPointerException - if the given file path is null.IllegalArgumentException - if the given file path is empty.IllegalArgumentException - if the given file path does not end with ".png".IllegalArgumentException - if the given file path belongs to a non-empty directory.IORuntimeException - if an I/O error prevents the image from being saved as a file.public BufferedImage takeDesktopScreenshot()
SecurityException - if readDisplayPixels permission is not granted.public void saveComponentAsPng(@Nonnull Component c, @Nonnull String imageFilePath)
Component and saves it as a PNG file.c - the given Component.imageFilePath - the path of the file to save the screenshot to.NullPointerException - if the given file path is null.IllegalArgumentException - if the given file path is empty.IllegalArgumentException - if the given file path does not end with ".png".IllegalArgumentException - if the given file path belongs to a non-empty directory.IORuntimeException - if an I/O error prevents the image from being saved as a file.@Nonnull public BufferedImage takeScreenshotOf(@Nonnull Component c)
Component.c - the given Component.Component.SecurityException - if readDisplayPixels permission is not granted.public void saveImage(@Nonnull BufferedImage image, @Nonnull String filePath)
image - the image to save.filePath - the path of the file to save the image to.NullPointerException - if the given file path is null.IllegalArgumentException - if the given file path is empty.IllegalArgumentException - if the given file path does not end with ".png".IllegalArgumentException - if the given file path belongs to a non-empty directory.IORuntimeException - if an I/O error prevents the image from being saved as a file.Copyright © 2014 AssertJ. All rights reserved.