Class SnapshotTaker


  • public class SnapshotTaker
    extends Object
    Takes a snapshot of a JComponent.
    Author:
    Nick Collier
    • Constructor Detail

      • SnapshotTaker

        public SnapshotTaker​(Imageable imageable)
      • SnapshotTaker

        public SnapshotTaker​(JComponent comp)
    • Method Detail

      • takeSnapshot

        public void takeSnapshot​(JComponent parent)
                          throws IOException
        Takes a snapshot of the Imageable associated with this Snapshot taker. This will display a file dialog.
        Parameters:
        parent - the component to center the file dialog over
        Throws:
        IOException - if there is an error taking the snapshot
      • save

        public void save​(File file,
                         String imageFormat)
                  throws IOException
        Saves the snapshot to the specified file and in the specified format.
        Parameters:
        file - the file to save the image to
        imageFormat - the image format. One of "bmp", "jpg", "tif", or "png".
        Throws:
        IOException - if there is an error saving the snapshot
      • createSnapshotAction

        public static Action createSnapshotAction​(JComponent comp)
        Creates an Action that will take a snapshot fo the specified JComponent when triggered.
        Parameters:
        comp - the component to take a snapshot of.
        Returns:
        an Action that will take a snapshot fo the specified JComponent when triggered.