Java:JTabbedPane 选项卡标题中的 JProgressBar(或等效项)
如果我真的想做类似的事情,我可以将 JProgressBar (或等效的)放在 JTabbedPane 选项卡中吗? (我的意思是,不是在选项卡本身中,
我该如何做类似的事情?
编辑我真的想将进度条放在选项卡的标题中,而不是选项卡本身。
这是一些 ASCII 艺术:
----------------------------------------------------
| Tab 1 || Tab 2||Tab-with-progress-bar||Tab 4|
----------- --------------------------------
' '
' '
' '
' '
' '
' '
' '
' '
----------------------------------------------------
)在第三个选项卡的 标题 中可见。
所以当前确实是“选项卡2
”,但我希望进度条(或同等内容 在 Java 1.5 上工作:这必须在无数永远不会配备 Java 6 的 MacOS 10.4 和 MacOS 10.5 Apple 计算机上工作(有些配备,有些不配备:而且很多永远不会配备,这不是我的决定)
If I really wanted to do something like that, can I put a JProgressBar (or it's equivalent) in a JTabbedPane tab? (I mean, not in the tab itself,
How would I do something like that?
EDIT I really do want to put the progressbar in the title of the tab, not the tab itself.
Here's some ascii art:
----------------------------------------------------
| Tab 1 || Tab 2||Tab-with-progress-bar||Tab 4|
----------- --------------------------------
' '
' '
' '
' '
' '
' '
' '
' '
----------------------------------------------------
So it's really "tab 2" that is currently visible, but I want the progress bar (or equivalent) to be visible in the third tab's title.
EDIT 2
This has to work on Java 1.5: this has to work on the countless MacOS 10.4 and MacOS 10.5 Apple computers that will never be equipped with Java 6 (some do, some don't: and quite a lot never will, it is not my call)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于早期版本,您可以尝试
addTab()
以及用于指示的Icon
的合适实现进步。For earlier versions, you might try
addTab()
with a suitable implementation ofIcon
used to indicate progress.将 JProgressbar 包含在 JPanel 中,并将该 JPanel 添加到 JTabbedPane。
编辑:来自 JTabbedPane JavaDoc:
因此,您基本上可以简单地将
new JLabel("Tab")
替换为对 JProgressbar 的引用(尽管不得将此 JProgressbar 添加到 Tab 本身)。不过,我认为这个方法在Java 1.6之前并不存在。
Enclose the JProgressbar in a JPanel and add that JPanel to the JTabbedPane.
Edit: From the JTabbedPane JavaDoc:
So you could basically simply replace
new JLabel("Tab")
by a reference to your JProgressbar (though this JProgressbar must not be added to the Tab itself).However, I think this method doesn't exist prior to Java 1.6.