Solved

take a screen shot and store it

Posted on 2004-09-07
9
214 Views
Last Modified: 2010-03-31

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
0
Comment
Question by:VolSpeak
9 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 125 total points
Comment Utility
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
 
LVL 18

Expert Comment

by:armoghan
Comment Utility
You can use
Runtime.getRuntime.exec()
to open the java file in some specific program
0
 

Author Comment

by:VolSpeak
Comment Utility

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
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
>>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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Expert Comment

by:michaelfriesy
Comment Utility
Its an open file, do you know of any work around?
0
 

Expert Comment

by:michaelfriesy
Comment Utility
Apologies, not double accounts with one user, theres two of us using the same system....
0
 

Expert Comment

by:michaelfriesy
Comment Utility
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
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
>>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
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
8-)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now