BufferedImage screenShotscreenShot = new Robot().createScreenCapture(new Rectangle((int)myPanel.getLocationOnScreen().getX(), (int)myPanel.getLocationOnScreen().getY(), myPanel.getWidth(), myPanel.getHeight()));
ImageIO.write(screenShot, "png", new File(pfadAusgabe));
Code:
Code:BufferedImage screenShotscreenShot = new Robot().createScreenCapture(new Rectangle((int)myPanel.getLocationOnScreen().getX(), (int)myPanel.getLocationOnScreen().getY(), myPanel.getWidth(), myPanel.getHeight())); ImageIO.write(screenShot, "png", new File(pfadAusgabe));
try
{
machWasBöses();
}
catch (AWTException dasIstDasExceptionObjektDasVielleichtVonObenAngeflogenKommt)
{
dasIstDasExceptionObjektDasVielleichtVonObenAngeflogenKommt.printStackTrace();
}
public class Screen{
public void printScreen(){
Panel myPanel=new Panel();
int i=1;
BufferedImage screenShot=new BufferedImage(350, 288, 2);
boolean test=false, test2=false;
while(test){
try{
screenShot = new Robot().createScreenCapture(new Rectangle((int)myPanel.getX(), (int)myPanel.getY(), myPanel.getWidth(), myPanel.getHeight()));
}catch(AWTException e){
e.printStackTrace();
test=true;
}
}
while(test2){
try{
ImageIO.write(screenShot, "jpg", new File("./Screenshots/Screenshot " + i));
}catch(IOException f){
f.printStackTrace();
test2=true;
}
}
}
}
BufferedImage screenShot=new BufferedImage(350, 288, TYPE_INT_RGB);
public class Screenshot{
public void printScreen(){
Rectangle rect=new Rectangle(int 500, int 200, int 350, int 288);
Robot rob=new Robot();
rob.createScreenCapture(rect);
}
}