Swing 中漂亮的 JPanel

发布于 2024-08-22 06:40:28 字数 588 浏览 8 评论 0原文

我目前正在努力使我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

花落人断肠 2024-08-29 06:40:28

既然您已经研究过 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.

谷夏 2024-08-29 06:40:28

是的,为什么不为此编写自己的自定义边框或 JPanel 呢?您可以通过重写 paintComponent 方法来自定义绘画。

Yes, why not write your own custom border or JPanel for that? You customize the painting by overriding the paintComponent-method.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文