如何让JFrame透明?
问题描述:
如何让JFrame透明化?我想让我的JFrame透明化。当我的JFrame位于其上时,用户应该看到背景。
How to make JFrame transparent? I want to make my JFrame transparent. User should see the background when my JFrame is on top of it.
答
如果您对使用受限API没有任何异议然后,您可以使用 AWTUtilities
类和 setWindowOpacity()
该类的方法执行此操作。 此处和这里是如何使用它的教程? 此处是使用Java本机访问的版本。
If you do not have any objection in using restricted API classes then you can do this with AWTUtilities
class and setWindowOpacity()
method of that class. Here and here is a tutorial on how to use it? And here is the version using Java native access.