1 Reply Latest reply on Jun 26, 2013 7:23 AM by mKorbel

    How to take a snap shot of a GUI in java




         I know how to use Robot class to take a screen shot. But, I would like to take a snap shot of a java Swing GUI.  How can I do that....How can I know the locations of Java GUI in the screen.


      Please let me know





        • 1. Re: How to take a snap shot of a GUI in java

          there no needed any active Screens Capture


          any JComponents including Containers can be printed to Image, BufferedImage


                  Dimension size = container.getSize();

                  BufferedImage image = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB);

                  Graphics2D g2 = image.createGraphics();


                  try {

                      ImageIO.write(image, "jpg", new File("snapshot.jpg"));

                  } catch (Exception e) {

                      // exceptions handling