java - 有没有办法在透明背景而不是 JFrame 本身上生成 JFrame 组件的图片?
问题描述
我有一种方法,它采用文件路径和文件名来保存当前表单的图片。但问题是,我希望它只保存框架的组件而不是框架背景。我真的是初学者,所以有人可以帮助我吗?
public void save(String imageFile, String path) throws InterruptedException {
Rectangle r = getBounds();
try {
BufferedImage i = new BufferedImage(r.width,r.height,
BufferedImage.TYPE_INT_RGB);
Graphics g = i.createGraphics();//getGraphics();
paintComponents(g);
ImageIO.write(i, "png", new File(imageFile,path));
} catch (IOException e) {
e.printStackTrace();
}
}
解决方案
推荐阅读
- amazon-web-services - 如何将标签附加到 AWS 分支
- firebase - 使用 Firebase SDK 对我的 React 应用程序进行 Google 分析
- python - Selenium Web-Driver 找不到元素(Selenium IDE 确实找到了它)
- ruby-on-rails - “.js 不存在于资产管道中”
- php - CakePHP - 使用保存关联保存到两个以上的模型
- java - 在java中,提供参数以扩展参数化接口的接口是它的同义词吗?
- spring - Spring boot Rest 创建一个可以引用另一个类别的类别或不
- c# - 我对订阅重复购买问题有疑问
- c++ - c ++模板化类,带有指向可变函数的函数指针
- c# - 如何将数组传递给 OracleParameter for IN 条件?