Reputation: 11
I have a third party Java applet that I am going to embed in my webpage but I don't have access to the applet code.
But I want to create a button on my page on clicking which will create a screenshot of the applet (but not the whole screen). I tried using the Robot class but that would take the whole screen which I don't want
BufferedImage screencapture = new Robot().createScreenCapture(
new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()) );
I was looking over the net and found code but those require access to the applet which I don't have.
Is it possible to do it using java? If so, how?
Upvotes: 0
Views: 461
Reputation: 168815
I see at least two options.
AppletContext.getApplet(name)
.Applet.getLocationOnScreen()
for the co-ordinates.Extend the original applet & add a new method to return or export an image of the current applet surface. See ComponentImageCapture.java for an example.
Options for exporting the image:
JFileChooser
/File
.Upvotes: 1