JTabbedPane 缩进
使用 JTabbedPane 时,如何缩进选项卡?
Swing 默认输出:
------- --------- ------
| A | | B | | C |
------------------------------
| |
| |
| |
| |
| |
所需的缩进输出:
------- --------- ------
| A | | B | | C |
------------------------------
| |
| |
| |
| |
| |
这看起来很简单,但我一直无法找到解决方案。 谢谢。
When using a JTabbedPane, how do you indent the tabs?
Swing default output:
------- --------- ------
| A | | B | | C |
------------------------------
| |
| |
| |
| |
| |
Desired indented output:
------- --------- ------
| A | | B | | C |
------------------------------
| |
| |
| |
| |
| |
This seems simple enough, but I have not been able to find the solution.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于所有选项卡式窗格,您可以将以下内容与默认 LAF 一起使用:
另请参阅: UIManager 默认值
对于单个选项卡式窗格,您可能需要重写 BasicTabbedPaneUI 类的“getTabAreaInsets()”方法以返回上述 Inset。
For all tabbed panes you can use the following with the default LAF:
See also: UIManager Defaults
For individual tabbed panes you would probably need to override the "getTabAreaInsets()" method of the BasicTabbedPaneUI class to return the above Inset.
如果无法使用简单的 JTabbedPane 来完成此操作,您可以使用以下(稍微不优雅)的解决方案:
创建您自己的组件,由 JTabbedPane 和 JPanel 组成。 JTabbedPane仅显示选项卡;就其而言,每个选项卡都是空的。 JPanel(使用 CardLayout)负责实际显示每个选项卡。将 ChangeListener 添加到 JTabbedPane,并使用它在 CardLayout 的卡片之间切换。
然后您所要做的就是在您自己的组件中布置 JTabbedPane 和 JPanel,您可以按照自己的喜好进行操作。这样您就可以将选项卡推到右侧。
If there's no way to do it with a simple JTabbedPane, you could use the following (slightly inelegant) solution:
Create your own component, consisting of a JTabbedPane and a JPanel. The JTabbedPane displays only the tabs; as far as it's concerned, each tab is empty. The JPanel (using a CardLayout) is responsible for actually displaying each tab. Add a ChangeListener to the JTabbedPane, and use it to switch between cards of the CardLayout.
Then all you have to do is lay out the JTabbedPane and the JPanel in your own component, which you can do however you like. That lets you push the tabs over to the right.