JTabbedPane 选项卡高度与 nimbus
我想更改高度选项卡的选项卡窗格,为此我尝试了多种方法但没有成功。首先,我尝试使用间隔图标,高度很好,但选项卡的文本不再居中。然后我尝试更改 Nimbus L&F 属性、TabbedPane.tabInsets、TabbedPane:TabbedPaneTab.contentMargins 和 TabbedPane:TabbedPaneTabArea.contentMargins 没有任何变化。最后我尝试扩展BasicTabbedPaneUI并覆盖calculateTabHeight,但选项卡的背景不再绘制。
I would like the change the height tab's tabbedpane, and to do so I tried several method without any success. First I tried with a spacer icon, the height is good, but the text of the tab is not center anymore. Then I tried to change Nimbus L&F properties, TabbedPane.tabInsets, TabbedPane:TabbedPaneTab.contentMargins, and TabbedPane:TabbedPaneTabArea.contentMargins nothing change. Finally I tried to extend BasicTabbedPaneUI and overide calculateTabHeight, but the background of the tab is not painted anymore.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需使用
setTabComponentAt
在选项卡上设置自定义组件即可。您可以设置任何您想要的组件。如果您只想要一个更大高度的标签,请为setComponentAt
提供一个带边框的 JLabel,或者设置其 PreferredSize。Just use
setTabComponentAt
to set a custom component on the tab. You can set any component you want. If you just want a label with a bigger height, givesetComponentAt
a JLabel with a border, or with its preferredSize set.