[英]Take a “screenshot” of 3rd party applet in my webpage
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. 我有一个第三方Java小程序,该程序将嵌入到我的网页中, 但是我无法访问小程序代码。
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). 但是我想在页面上单击创建一个按钮,该按钮将创建该applet的屏幕截图(而不是整个屏幕)。 I tried using the Robot class but that would take the whole screen which I don't want
我尝试使用Robot类,但是那样会占用整个屏幕,我不需要
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. 我在网上查找并找到了代码,但是那些代码需要访问我没有的applet。
Is it possible to do it using java? 是否可以使用Java做到这一点? If so, how?
如果是这样,怎么办?
I see at least two options. 我至少看到两个选择。
AppletContext.getApplet(name)
. AppletContext.getApplet(name)
获得对该applet的引用。 Applet.getLocationOnScreen()
for the co-ordinates. Applet.getLocationOnScreen()
作为坐标。 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.
有关示例,请参见ComponentImageCapture.java 。
Options for exporting the image: 导出图像的选项:
JFileChooser
/ File
. JFileChooser
/ File
对小程序进行数字签名,将图像导出到本地文件系统。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.