JTabbedPane:标签本身之前和之后的组件 [英] JTabbedPane: Components before and after the tabs themselves

查看:108
本文介绍了JTabbedPane:标签本身之前和之后的组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这与

我已经想出了按钮 -​​ 我的想法,但我宁愿有一个JTabbedPane,因为这真的是它的样子,但装饰着一个按钮或两侧的图标。



我已经看到 laf-widget 项目为几个LaF做了类似的事情(标签左边的放大镜图标)。然而,我必须承认,我还不够了解他是如何做到的 - 而且它看起来像一个有点复杂的过程,从而物理上改变了所讨论的LaF(字节码操纵它),注入了laf -widget的东西到UI委托 - 我仍然不知道JTabbedPane或TabbedPaneUI实际上是如何调制注入该图标/按钮。

解决方案 div>

我终于问Kirill 物质LaF / laf-widget如何他设法在laf-widget的标签前面放置一个按钮来装饰JTabbedPanes,这是他的回复:


它依赖于在
BasicTabbedPaneUI.tabAreaInsets字段
中为按钮腾出空间,
按钮的自定义setBounds将
组件放置在
区域中。



有关更多代码,请参阅TabOverviewButton
以及
laf-widget项目中的TabOverviewDialogWidget类。



通常,选项卡窗格UI
委托是最少
之一有吸引力的提高,因为它
有很多私人和包
保护方法


谢谢,基里尔!

This is similar to the question How to build a Google-chrome tabs and menubar interface in Java Swing? (I want to accomplish the same), but more to the point: How do I put components in front and behind the tabs in a JTabbedPane?

I've already come up with the buttons-idea myself, but I'd rather have a JTabbedPane, since that is really what it is, but decorated with a button or icons on the sides.

I've seen that the laf-widget project from Kirill does something like it (the magnifying-glass icon to the left of the tabs) for several LaFs. However, I must admit that I'm not yet well enough versed to understand how he does it - and also it seems like a somewhat complicated process, whereby one "physically" change the LaF in question (bytecode manipulates it), injecting the laf-widget stuff into the UI delegates - and I still don't know how the JTabbedPane or TabbedPaneUI is actually modulated to inject that icon/button.

解决方案

I finally asked Kirill of Substance LaF/laf-widget of how he manages to put a button in front of the tabs in the laf-widget that decorates JTabbedPanes, and this is his reply:

It relies on the BasicTabbedPaneUI.tabAreaInsets field to make room for the button, and custom setBounds of the button component to position itself in that area.

For more code, see TabOverviewButton and TabOverviewDialogWidget classes in the laf-widget project.

In general, the tabbed pane UI delegate is one of the least attractive ones to enhance since it has a lot of private and package protected methods

Thanks, Kirill!

这篇关于JTabbedPane:标签本身之前和之后的组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆