使 Swing-JTabbedPane-Tab 填充其容器的整个宽度的最简单方法
我在 JPanel 中有一个 JTabbedPane (顶部有水平选项卡),我希望此 JTabbedPane 的选项卡适合 JPanel 的整个宽度,这样如果只有一个选项卡,该选项卡将填充整个宽度;当有两个选项卡时,每个选项卡将恰好填充一半,依此类推。
使用自定义 JComponent 作为选项卡的标题并设置 PreferredSize 没有解决方案,因为 JTabbedPanel 似乎在标题组件周围放置了某种边框。
有没有比扩展和/或重写部分/全部 JTabbedPane 更简单的解决方案?
(也许我应该补充一点,当我谈论选项卡时,我指的是这些您可以单击以切换显示的组件的导航组件,而不是组件本身。)
I'm having a JTabbedPane (with horizontal tabs on the top) in a JPanel, and I want the tabs of this JTabbedPane to fit the whole width of the JPanel, so that if there's only one tab, the tab would fill the whole width; when there are two tabs, each tab would fill excactly the half, and so on.
Using a custom JComponent as a the title of the tabs and setting the PreferredSize there isn't a solution since it seems that JTabbedPanel puts some sort of border around the title-components.
Is there any easier solution than extending and/or rewriting part/all of JTabbedPane?
(Maybe I should add that when I'm talking about tabs, I refer to these navigational components you can click on to switch the component shown, and not the components themselves.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
测试这段代码:
Test this code :