take a screen shot and store it


Hi, I want to take a screenshot of a particular screen on on my system and store it as a jpeg. Is it possible to do this? If so how do I specify where to save the screen shot on my pc? Also is it possible to specify what program I want the jpeg (just this specific jpeg, not all jpegs on the system) to open with? in this case mozilla firebird. Thanks
VolSpeakAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
Try

Rectangle screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
BufferedImage bi = new Robot.createScreenCapture(screenRect);
ImageIO.writeImage(bi, "jpg", new FileOutputStream("screen.jpg");

What program opens a jpeg is not a Java issue - it's an OS one
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
armoghanCommented:
You can use
Runtime.getRuntime.exec()
to open the java file in some specific program
0
VolSpeakAuthor Commented:

Thanks for that CEHZ, this is the code im using:

  // capture the whole screen
BufferedImage screencapture = new Robot().createScreenCapture(
   new Rectangle(10, 10, 900, 750));
   
   // Save as JPEG
     File file = new File("screencapture.jpg");
     ImageIO.write(screencapture, "jpg", file);

For a points increase:
 The screen I want to capture has a scroll, is it possible to include the unscrolled part of the screen in the capture as well?
0
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

CEHJCommented:
>>is it possible to include the unscrolled part of the screen in the capture as well?

AFAIK - no. Only what's visible. btw what kind of desktop scrolls?
0
michaelfriesyCommented:
Its an open file, do you know of any work around?
0
michaelfriesyCommented:
Apologies, not double accounts with one user, theres two of us using the same system....
0
michaelfriesyCommented:
Ive just had an idea, can the resolution of the screen be changed using java so the whole file will be within the window?
0
CEHJCommented:
>>can the resolution of the screen be changed using java so the whole file will be within the window?

Yes, but not without JNI or a Runtime.exec call
0
CEHJCommented:
8-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.