public class ScreenshotTaker extends Object implements ScreenshotTakerIF
Component
s.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)
ScreenshotTakerIF
saveDesktopAsPng
in interface ScreenshotTakerIF
imageFilePath
- the path of the file to save the screenshot to.public BufferedImage takeDesktopScreenshot()
ScreenshotTakerIF
takeDesktopScreenshot
in interface ScreenshotTakerIF
public void saveComponentAsPng(@Nonnull Component c, @Nonnull String imageFilePath)
ScreenshotTakerIF
Component
and saves it as a PNG file.saveComponentAsPng
in interface ScreenshotTakerIF
c
- the given Component
.imageFilePath
- the path of the file to save the screenshot to.@Nonnull public BufferedImage takeScreenshotOf(@Nonnull Component c)
ScreenshotTakerIF
Component
.takeScreenshotOf
in interface ScreenshotTakerIF
c
- the given Component
.Component
.public void saveImage(@Nonnull BufferedImage image, @Nonnull String filePath)
ScreenshotTakerIF
saveImage
in interface ScreenshotTakerIF
image
- the image to save.filePath
- the path of the file to save the image to.Copyright © 2014–2019 AssertJ. All rights reserved.