清除透明窗口上的 JFrame 背景
我有一个透明的 JFrame AWTUtilities.setWindowOpaque(this, false); 我在调整窗口大小时遇到问题。我需要一些可以在绘制之前清除窗口背景的东西,我需要使其所有背景为空且透明。现在这幅画是在旧背景上画的,看起来很难看。 我尝试在背景上绘制透明图像,但我遇到了同样的问题。
i have a transparent JFrame AWTUtilities.setWindowOpaque(this, false);
I have a problem when resizing the window. I need something that could clear the background of the window before drawing on it,I need to make it all the background empty and transparent. Now the painting is draw over the old background and looks ugly.
I tried to draw a transparent image over the background but i have same issues.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您有一个不透明的组件,您将完全负责绘制其内容。窗口系统或 AWT 不执行任何操作来将背景设置为某种定义的状态。
所以至少你应该做一些类似基本 Canvas 代码的事情,
“透明”到底是什么意思。您想浏览桌面吗?您想看到组件后面的面板吗(那么至少它不应该是“不透明的”)。
If you have an opaque component you're completely responsible for drawing its content. The windowing system or AWT does NOTHING to set the background to some defined state.
So at least you should do something like the basic Canvas code
What exactly do you mean with "transparent". Do you want to look through to the desktop? Do you want to see panel behind your component (then at least it should not be "opaque").