code_junkie

Capturing heavyweight java components?

Nov 12th, 2011
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. robot.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
  2.  
  3. Point p = yourAwtComponent.getLocationOnScreen();
  4. int w = yourAwtComponent.getWidth();
  5. int h = yourAwtComponent.getHeight();
  6.  
  7. Rectangle rectangle = new Rectangle( p.x, p.y, w, h );
  8.  
  9. Image image = robot.createScreenCapture(rectangle);
  10.  
  11. ImageIO.write( image, "png", file );
  12.  
  13. int width = frameContainer.getWidth();
  14. int height = frameContainer.getHeight();
  15.  
  16. BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
  17. Graphics2D g2 = image.createGraphics();
  18.  
  19. frameContainer.paint(g2);
  20.  
  21. return image;
Add Comment
Please, Sign In to add comment