@Override public void actionPerformed(ActionEvent arg0) { if (arg0.getSource() == startStop) { // switch to/from editmode editMode = !editMode; // equence();//TODO do sequence } else if (arg0.getSource() == screenShot) { // save the image from viewport to the disk (named with date) DateFormat dateFormat = new SimpleDateFormat("yyyy_MM_dd HH_mm_ss"); Date date = new Date(); String sDate = dateFormat.format(date); try { BufferedImage bi = viewport.getImage(); String path = tPath.getText() + sDate + ".png"; // directory where the screenshot is saved System.out.println("PATH: " + path); File outputfile = new File(path); // make output file string ImageIO.write(bi, "png", outputfile); } catch (IOException e) { System.out.println("There was a problem saving the image!"); } } }
@Override public void performTask() { viewport.update(); scene.paint(viewport); sendToScreen(viewport.getImage()); }