【问题标题】:How to programmatically click a tab in JTabbedPane?如何以编程方式单击 JTabbedPane 中的选项卡?
【发布时间】:2013-06-12 18:28:00
【问题描述】:

我在我的应用程序顶部使用玻璃窗格。但是我希望 JTabbedPane 是可点击的。我知道如何通过在玻璃窗格上添加鼠标侦听器来使用 JButton 执行此操作,然后使用来自 SwingUtilities 的此方法getDeepestComponentAt() 。但是,当我对 JTabbedPane 执行相同操作时,我可以使用此方法检索 JTabbedPane 实例,但我想选择用户单击的选项卡。我不能使用setSelectedIndex(..)(至少不能直接使用),因为我在内容窗格上只有一个点。谁知道如何允许选项卡选择?

这基本上就是我使用按钮的方式:http://docs.oracle.com/javase/tutorial/uiswing/components/rootpane.html(查看玻璃窗格的示例)。

【问题讨论】:

    标签: java swing jtabbedpane


    【解决方案1】:

    你试过 JTabbedPane 的indexAtLocation(int, int)吗?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-23
      • 1970-01-01
      相关资源
      最近更新 更多