protected void onSaveImage() { System.out.println("application stop this !!!"); offScreenCanvas3D.renderOffScreenBuffer(); offScreenCanvas3D.waitForOffScreenRendering(); System.out.println("Rendered to offscreen"); try { FileOutputStream fileOut = new FileOutputStream("C://image.jpg"); JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(fileOut); encoder.encode(imageComponent.getImage()); fileOut.flush(); fileOut.close(); } catch (Exception e) { System.err.println("Failed to save image: " + e); }