我有一个小问题,我真的不知道如何解决,基本上我想拍摄我的桌面的截图(使用"机器人"类),不包括实际的程序GUI组件.最初我相信它可以通过临时隐藏组件来完成,但每次制作新的屏幕截图时,组件都包含在图像中.
这是截取的按钮的actionPerformed方法中包含的块:
if (command.equals("zoom")) {
setComponentVisability(false);//try to hide the components from the robot
zt.screenShoot();//take the screenshot
setComponentVisability(true);//show the components
}
Run Code Online (Sandbox Code Playgroud)
"zt.screenShoot"获取屏幕截图并将其返回到新的JFrame(用于调试),在我的主框架中我正在使用
com.sun.awt.AWTUtilities.setWindowOpaque(systemWindow, false);
Run Code Online (Sandbox Code Playgroud)
使背景透明的方法; 不确定这是否与此问题有关.
任何帮助都会很棒,谢谢