我正在尝试使用Robot
类在我的 JavaFX 应用程序中捕获屏幕截图,
这是我在我的应用程序中使用的代码:
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()));
它在windows 操作系统headless environment
中运行良好,但在MAC OS中显示错误Robot robot = new Robot();