在 JTabbedPane 中将选项卡置于最前面 [英] Bringing tab to front in JTabbedPane
问题描述
当我在 JTabbedPane
对象上使用 setSelectedComponent
或 setSelectedIndex
时,面板总是出现在我的 UI 中.但是,有时与面板关联的选项卡仍处于隐藏状态.换句话说,选项卡不会滚动到选项卡式窗格的可见部分.
When I use setSelectedComponent
or setSelectedIndex
on a JTabbedPane
object, the panel always comes up in my UI. However, sometimes the tab associated with the panel remains hidden. In other words, the tab does not scroll to a visible portion of the tabbed pane.
我该如何解决这个问题?我已经尝试了俗气的选择一个索引,然后选择所需的索引,以及其他一些更优雅的东西,但是 arrrrgh!!
How can I fix this? I have tried the cheesy select one index, then select desired index, as well as several other more elegant things, but arrrrgh!!
如果可以,请帮助我.
谢谢,托德
推荐答案
我认为您的电话不是在 EDT 上完成的.用 SwingUtilities.invokeLater
I think your call is not done on EDT. Wrap it with SwingUtilities.invokeLater
这篇关于在 JTabbedPane 中将选项卡置于最前面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!