I\'m writing my first lines of code after 2 years of managerial work. No time to read a lot of docs, need to create a proof-of-concept just in minutes. So I have to work wi
try {
Robot pixelGrabber = new Robot();
BufferedImage bi = pixelGrabber
.createScreenCapture(new Rectangle(x, y, width, height));
Image screen = SwingFXUtils.toFXImage(bi,
new WritableImage(bi.getWidth(), bi.getHeight()));
} catch (AWTException ex) {
ex.printStackTrace();
}
This creates a screenshot starting on pixel x*y with your needed height and width independent of the current size of your application window. If your are using JavaFX, just use SwingFXUtils to transform the awt-image to a JavaFX-image.