• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

desktop ScreenShot

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 )
 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 527
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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]

------------------
 
Ranch Hand
Posts: 247
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
catch(AccessControlException e) { }
instead of
catch(Exception e) { }

------------------
Happy Coding,
Gregg Bolinger
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
He was giving me directions and I was powerless to resist. I cannot resist this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic