I am trying to capture screenshots in my JavaFX application using the Robot class,
this is the code i used in my application:
Rectangle screenBounds = new Rectangle(Screen.getPrimary().getBounds().getWidth(), Screen.getPrimary().getBounds().getHeight()); Robot robot = new Robot(); BufferedImage img = robot.createScreenCapture(new java.awt.Rectangle( (int) screenBounds.getX(), (int) screenBounds.getY(), (int) screenBounds.getWidth(), (int) screenBounds.getHeight()));
It works fine on Windows, but shows a headless environment error on MAC OS in Robot robot = new Robot();
Shreyas dave
source share