Swing 中漂亮的 JPanel
我目前正在努力使我的 Swing 应用程序看起来更好。我想实现以下目标:
这个想法是让每个框都有一个漂亮的标题,其背景类似于上图。使用基本 Swing 组件,我能得到的最接近的结果是添加 TitledBorder,但这与我想要的完全不一样。
我用 SwingX 的 JXTaskPane 进行了实验,它很接近:
http://img411.imageshack。 us/img411/6866/image431.png
几乎完美,除了它是可折叠的并且似乎不可能使其不折叠。
我在这里缺少任何明显的解决方案吗?否则,我想扩展 JPanel 并使用标题背景的图像为其创建一个特殊的标题。
任何指示都非常感激。谢谢。
I'm currently working on making my Swing application look better. I want to achieve something along these lines:
The idea is for each box to have a pretty header with a background similar to the above image. The closest I can get to anything like this using basic Swing components is adding a TitledBorder but this is nothing close to what I want.
I have experiment with JXTaskPane from SwingX, which is close:
http://img411.imageshack.us/img411/6866/image431.png
And near perfect, except for the fact that it's collapsible and it doesn't appear possible to make it not collapsible.
Are there any obvious solutions I'm missing here? Otherwise I figure extending JPanel and creating a special header for it using a image for the background of the header.
Any pointers greatly appreciated. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
既然您已经研究过 SwingX 组件,为什么不使用 JXTitledPanel 呢?我认为这非常接近您想要实现的目标。您可以在那里设置自己的颜色。
Since you already looking into SwingX components, why don't you use JXTitledPanel? I think it is very close to what you want to achieve. You can set your own colors there.
是的,为什么不为此编写自己的自定义边框或 JPanel 呢?您可以通过重写 paintComponent 方法来自定义绘画。
Yes, why not write your own custom border or JPanel for that? You customize the painting by overriding the paintComponent-method.