<< Previous question: Determine image file width / height
Next question: Access image pixels >>
You can grab pixels from the screen using java.awt.Robot's createScreenCapture
method if you are using Java 1.3 or higher (demo code for screen capturing in Java).
However, a cleaner approach is to
Image object that has the size of the component that you want to save,
Graphics object for that image and
Graphics object to
the component's paint method.
See this Sun article for some code. The actual image saving is not covered by that article, refer to the corresponding section in this FAQ. Note that unless a canvas only stores a photo, JPEG is not the appropriate file format to store the image. Use PNG or some other format with lossless compression instead.