Are there any java.awt.Graphics
methods that I can use to copy a rectangular portion of my current screen and store it as an image variable? If not what are the best alternatives I could use?
Asked
Active
Viewed 114 times
0

Andrew Thompson
- 168,117
- 40
- 217
- 433

user2503387
- 1
- 1
-
Are you attempting to capture the *current* screen, or the *applet's* display? This clarification is necessary. – FThompson Jun 20 '13 at 16:22
-
I am trying to copy a portion of just the applet's display. I understand the robot class approach in the answer below, and have used it before, but I am looking to just find images in the applet. – user2503387 Jun 20 '13 at 19:38
1 Answers
2
If the applet is signed and has enough permission, java.awt.Robot
is available.
Robot robot = new Robot();
Rectangle rect = new Rectangle(0, 0, displayMode.getWidth(), displayMode.getHeight());
BufferedImage image = robot.createScreenCapture(rect);

zakki
- 2,283
- 14
- 20
-
This will only work if the applet's display is on top of all other windows, and this offers no cropping to a "portion of the applet screen". While this answer may be a start, it is far from complete. – FThompson Jun 20 '13 at 16:20