gpt4 book ai didi

java - JTabbedPane:选项卡本身之前和之后的组件

转载 作者:行者123 更新时间:2023-12-02 08:37:58 28 4
gpt4 key购买 nike

这类似于问题How to build a Google-chrome tabs and menubar interface in Java Swing? (我想完成同样的任务),但更重要的是:如何将组件放在 JTabbedPane 中选项卡的前面和后面?

我自己已经提出了按钮的想法,但我宁愿有一个 JTabbedPane,因为它确实如此,但侧面装饰有按钮或图标。

我已经看到 laf-widget Kirill 的项目为几个 LaF 做了类似的事情(选项卡左侧的放大镜图标)。然而,我必须承认,我还不够熟练,无法理解他是如何做到这一点的——而且这似乎是一个有点复杂的过程,其中一个人“物理地”改变有问题的 LaF(字节码操纵它),注入(inject) laf -将小部件内容放入 UI 委托(delegate)中 - 我仍然不知道 JTabbedPane 或 TabbedPaneUI 实际上是如何调制以注入(inject)该图标/按钮的。

最佳答案

我终于问了 Substance LaF 的基里尔/laf-widget 他如何设法在 laf-widget 的选项卡前面放置一个按钮来装饰 JTabbedPanes,这是他的回复:

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

谢谢,基里尔!

关于java - JTabbedPane:选项卡本身之前和之后的组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/888856/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com