• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

desktop ScreenShot

 
Alex Iordache
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 219
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Brett Spell
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 527
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The first place to look for such things would be Sun's Java documentation page - in this case, specifically here.
 
Grace Lo
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We are using JDK 1.2.
Is there any smilar thing as Robot class in jdk 1.2?
Thanks,
Grace
 
Pratik Khetia
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 247
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
 
cs sakthi
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
catch(AccessControlException e) { }
instead of
catch(Exception e) { }

------------------
Happy Coding,
Gregg Bolinger
 
subir talukder
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic