title: How to capture only a desired portion of screen using createScreenCapture
body: <p>The following code captures the screen:    </p>
  
  <pre><code>import java.awt.Dimension;
  import java.awt.Rectangle;
  import java.awt.Robot;
  import java.awt.Toolkit;
  import java.awt.image.BufferedImage;
  
  
  public class capture{
      public static void main(String args[]) { 
  
          try { 
              Dimension size = Toolkit.getDefaultToolkit().getScreenSize(); 
              Robot robot = new Robot(); 
              BufferedImage img = robot.createScreenCapture(new Rectangle(size)); 
          } catch(Exception e) { 
          } 
  
      }
  }
  </code></pre>
  
  <p>Is there a way, to capture only a desired portion of the screen (e.g. a rectangle, from one x,y point to another)?</p>