Hi list


I been developing of JAVA SERVER. I'm using
java.awt.Robot class to capture the screen image .. 

But i'm getting few problem . Following is a simple
Frame Java program to capture the screen . 

The problem is well stated in the program .. I'll be
very much glad if anyone can solve the 

problem or give me a alternative for this problem...
Thx
Raj
I have used win2k and jdk1.3
-----------------------------------screencapture.java---------------------------------------

import java.awt.*; 
import java.awt.event.*; 
import java.awt.image.*; 
import javax.swing.*; 
import java.awt.Robot;
public class capturescreen2 extends JFrame 
    { 
    BufferedImage img = null; 
    Robot r = null; 
    Toolkit ct = null;
    public capturescreen2()
         { 
        getContentPane().setLayout(null); 
               r = new Robot(); 
                ct = Toolkit.getDefaultToolkit(); 
         } 
JButton button = new JButton("Capture"); 
button.setBounds(10,10,100,25); 
button.addActionListener 
( 
new ActionListener() 
    { 
    public void actionPerformed(ActionEvent e) 
        { 
        /************************************READ ME
********************************
the main problem is with BufferedImage img =
r.createScreenCapture(new Rectangle(x,y,w,h));
             But if u write this then compiler gives a
error as to the comversion is not 

appropriate i.e. you have to convert a Image "
r.createScreenCapture(new Rectangle(x,y,w,h))"
into BufferedImage "img". 
 
            there are two soluction for this 
1. Explicit casting 

BufferedImage img =
(BufferedImage)r.createScreenCapture(new
Rectangle(x,y,w,h));

it gives 
-------------error--------------
#
# HotSpot Virtual Machine Error,
EXCEPTION_ACCESS_VIOLATION
#
# Error ID: 4F533F57494E13120E43505002B0
#
--------------------------------
2.To cast it with constructor
BufferedImage(width,height,imagetype)
for this i been using a tempimg ( a obj of Image) and
then creating the 'img' obj using this 

constructor.
again the problem is that according to java1.3 help
doc the predefined image types: 

TYPE_BYTE_BINARY or TYPE_BYTE_INDEXED to get this we
can use getType(). i have assumed imagetype 

= 2 . This time it runs but with nothing to show
inside the frame :( 
***********************************READ ME
********************************/

// this is 1 option 
 img = (BufferedImage) r.createScreenCapture(x,y,w,h);



/* this is 2nd option 

Image tempimg = null;

tempimg =  r.createScreenCapture(x,y,w,h); 

*******> tempimp.getType() = 2 ( or 1 ) but not 0
assume;

img = new BufferedImage(w-x,h-y,2);



*/
    repaint(); 
    } 
} 
); 
getContentPane().add(button); 
addWindowListener(new WindowAdapter() { public void
windowClosing(WindowEvent e)  { 

System.exit(0);} }); 
} 
public void paint(Graphics g) 
{ 
super.paint(g); 
if (img != null) 
g.drawImage(img,10,70,(int)ct.getScreenSize().getWidth(),(int)ct.getScreenSize().getHeight(),this

); 
} 

public static void main(String argv[]) 
{ 
capturescreen2 frame = new capturescreen2(); 
frame.setBounds(50,50,300,300); 
frame.setVisible(true); 
} 
}
-----------------------------------------end 
screencapture.java--------------------------------

__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/
---------------------------------------------------------------------
To unsubscribe, send a message with the line: unsubscribe vnc-list
to [EMAIL PROTECTED]
See also: http://www.uk.research.att.com/vnc/intouch.html
---------------------------------------------------------------------

Reply via email to