code: public static ScreenCapture of(Dimension dimensions) throws IOException {
      ScreenCapture capture = new ScreenCapture(dimensions);
  
      try {
        capture.take();
      } catch (AWTException e) {
        throw new IOException(e);
      }
  
      return capture;
    }
docs: Takes a screen capture of the given dimensions.
  
  @param dimensions the dimensions of which to take a screen capture
  @return a capture of the designated dimensions
  @throws IOException if an I/O exception occurs