[英]Using an image instead of JDialog/frame to hold swing components?
I currently have a JDialog (class that implements JDialog and is constructed like a jframe), and has 3 swing buttons placed on it. 我目前有一个JDialog(实现JDialog并像jframe一样构造的类),并在上面放置了3个摆动按钮。 Currently I have it set, undecorated = true, to hide the outer frame.
目前,我将其设置为undecorated = true,以隐藏外部框架。 Is there any way to use my image to replace the default square frame?
有什么方法可以使用我的图像替换默认的方形框架?
This is what I aim for : 这是我的目标:
The blue square with shadow is the pre made image. 带有阴影的蓝色正方形是预制的图像。
Regards 问候
The blue square with shadow is the pre made image.
带有阴影的蓝色正方形是预制的图像。
Well, the best way would be to set the background of the panel and then add a ShadowBorder
to the panel. 好吧,最好的方法是设置面板的背景,然后将
ShadowBorder
添加到面板。 This will provide you with far more flexibility in the future as you can create many panels with different colors and reuse the same ShadowBorder instead of having to create an Image every time. 这将为您将来提供更大的灵活性,因为您可以创建许多具有不同颜色的面板并重复使用相同的ShadowBorder,而不必每次都创建图像。 I don't have an example of a ShadowBorder, but you might find one if you search the web.
我没有ShadowBorder的示例,但是如果您在网上搜索,可能会找到一个示例。
Is there any way to use my image to replace the default square frame?
有什么方法可以使用我的图像替换默认的方形框架?
But if you really want to use your premade Image, then you can just: 但是,如果您真的想使用预制图像,则可以:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.