permaculture playing cards*
The moose likes Java in General and the fly likes desktop ScreenShot Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "desktop ScreenShot" Watch "desktop ScreenShot" New topic
Author

desktop ScreenShot

Alex Iordache
Ranch Hand

Joined: Mar 13, 2001
Posts: 62
how to get a system desktop ScreenShot image in Java Application?
I'll use to create Frame transpaernt effect. (Linux and windows NT/2000 .JDK 1.3 )
Brett Spell
Ranch Hand

Joined: Feb 24, 2001
Posts: 92
Alex,
If you're using Java 1.3, you can do this easily using the new Robot class that's defined in the java.awt package. That class includes a createScreenCapture() method that returns a BufferedImage representing the contents of a rectangular portion of your screen. To determine how large the screen is, you can use the getScreenSize() method in AWT's Toolkit class, and I've included an example below of how to do this:

------------------
Brett Spell
Author, Professional Java Programming
ryan burgdorfer
Ranch Hand

Joined: Jan 24, 2001
Posts: 219
That is very cool! It sounds like I should switch from jdk 1.2.2 to 1.3 asap! Brett, in your book, do you cover alot of the new features introduced with the jdk 1.3?
------------------
  • Ryan Burgdorfer
  • Java Acolyte in
  • Columbus, OH USA


<UL TYPE=SQUARE><I><LI>Ryan Burgdorfer<BR><LI>Java Acolyte</I></UL>
Brett Spell
Ranch Hand

Joined: Feb 24, 2001
Posts: 92
Ryan,
I can't say that I specifically made a point to cover things that were introduced in 1.3, but the topics that are covered were written about from a 1.3 perspective.
------------------
Brett Spell
Author, Professional Java Programming
Anil Vupputuri
Ranch Hand

Joined: Oct 31, 2000
Posts: 527
Originally posted by Brett Spell:
Ryan,
I can't say that I specifically made a point to cover things that were introduced in 1.3, but the topics that are covered were written about from a 1.3 perspective.

What are the new API's added in Jdk1.3

SCJP 1.5, SCEA, ICED (287,484,486)
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
The first place to look for such things would be Sun's Java documentation page - in this case, specifically here.


"I'm not back." - Bill Harding, Twister
Grace Lo
Greenhorn

Joined: May 03, 2001
Posts: 12
We are using JDK 1.2.
Is there any smilar thing as Robot class in jdk 1.2?
Thanks,
Grace


Grace
Pratik Khetia
Ranch Hand

Joined: Jun 29, 2001
Posts: 50
I have an issure creating the buffered image with the following code. Infact I dont know how do I display the image which is created using the following code.
BufferedImage image = robot.createScreenCapture(rect);
Could you please write me in detail how do I display the following image in a JFrame or JEditorPane.
thanks
Pratik
If you're using Java 1.3, you can do this easily using the new Robot class that's defined in the java.awt package. That class includes a createScreenCapture() method that returns a BufferedImage representing the contents of a rectangular portion of your screen. To determine how large the screen is, you can use the getScreenSize() method in AWT's Toolkit class, and I've included an example below of how to do this:

[/B]

------------------
Gerry Giese
Ranch Hand

Joined: Aug 02, 2001
Posts: 247
Check out the tutorials on java.sun.com. Here's a link to one of them:
http://java.sun.com/docs/books/tutorial/uiswing/painting/drawingImages.html
Click on the ImageDisplayer.java file to see the source code. It's pretty straightforward. You can also go to the following for info on BufferedImage:
http://java.sun.com/j2se/1.3/docs/guide/2d/spec/j2d-image.fm2.html
I'm pretty sure that all you need to do is override the paint() method similar to the following to display the image:
<pre>
public void paint(Graphics g)
{
Graphics2D g2D = (Graphics2D) g;
g2.drawImage( image, 0, 0, this );
}
</pre>

CJP (Certifiable Java Programmer), AMSE (Anti-Microsoft Software Engineer)
Author of Posts in the Saloon
cs sakthi
Greenhorn

Joined: May 11, 2001
Posts: 15
Hi Friends,
I tried of using the following code for capturing the screen image but i'm getting exception like this,
Error java.security.AccessControlException: access denied (java.awt.AWTPermission createRobot)
For the code below,
try
{
AWTPermission per = new AWTPermission( "createRobot" );
Robot robot = new Robot();
BufferedImage image = robot.createScreenCapture(rect);
img = (Image)image;
}
catch( Exception e )
{
System.out.println(" Error "+e.toString());
}
What i've to do please let me know.
Thanx in advance,
Sakthi.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

catch(AccessControlException e) { }
instead of
catch(Exception e) { }

------------------
Happy Coding,
Gregg Bolinger


GenRocket - Experts at Building Test Data
subir talukder
Greenhorn

Joined: Dec 11, 2001
Posts: 2
I am using createSreenCapture method when my Windows2K machine is set to use 256 colors.The colors in the image are getting distorted at some places.Any idea why this is happening?
Regards
Subir
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: desktop ScreenShot
 
Similar Threads
is this table is not good or not normalize
Pre-assessment test from Oracle
why collection.sort gives compiler error?
Downloading Java
Which Virtualization system ? secure ?