You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.2 KiB
40 lines
1.2 KiB
15 years ago
|
package net.yacy;
|
||
17 years ago
|
|
||
|
import java.awt.Dimension;
|
||
|
import java.awt.Rectangle;
|
||
|
import java.awt.Robot;
|
||
|
import java.awt.Toolkit;
|
||
|
import java.awt.image.BufferedImage;
|
||
|
import java.io.File;
|
||
|
|
||
|
import javax.imageio.ImageIO;
|
||
|
|
||
|
|
||
|
public class screenshot {
|
||
|
/*
|
||
|
try {
|
||
|
Robot robot = new Robot();
|
||
|
|
||
|
Rectangle area = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
|
||
|
BufferedImage bufferedImage = robot.createScreenCapture(area);
|
||
|
|
||
|
} catch (AWTException e) {
|
||
|
}
|
||
|
*/
|
||
17 years ago
|
public static void main(final String[] args) throws Exception {
|
||
17 years ago
|
|
||
17 years ago
|
final Toolkit toolkit = Toolkit.getDefaultToolkit();
|
||
|
final Dimension screenSize = toolkit.getScreenSize();
|
||
|
final Rectangle screenRect = new Rectangle(screenSize);
|
||
17 years ago
|
// create screen shot
|
||
17 years ago
|
final Robot robot = new Robot();
|
||
|
final BufferedImage image = robot.createScreenCapture(screenRect);
|
||
|
final String outFileName = "test.png";
|
||
17 years ago
|
// save captured image to PNG file
|
||
|
ImageIO.write(image, "png", new File(outFileName));
|
||
|
// give feedback
|
||
|
System.out.println("Saved screen shot (" + image.getWidth() + " x " + image.getHeight() + " pixels) to file \"" + outFileName + "\".");
|
||
|
|
||
|
}
|
||
|
}
|