模块 java.desktop

类 JTabbedPane

所有已实现的接口:
ImageObserver , MenuContainer , Serializable , Accessible , SwingConstants

@JavaBean (defaultProperty ="UI", description ="A component which provides a tab folder metaphor for displaying one component from a set of components.") public class JTabbedPane extends JComponent implements Serializable , Accessible , SwingConstants
允许用户通过单击具有给定标题和/或图标的选项卡在一组组件之间切换的组件。有关使用选项卡式窗格的示例和信息,请参阅 如何使用选项卡式窗格The Java Tutorial 中的一个部分。

使用 addTabinsertTab 方法将选项卡/组件添加到 TabbedPane 对象。选项卡由与其添加位置对应的索引表示,其中第一个选项卡的索引等于 0,最后一个选项卡的索引等于选项卡计数减 1。

TabbedPane 使用 SingleSelectionModel 来表示选项卡索引集和当前选定的索引。如果选项卡计数大于 0,那么总会有一个选定的索引,默认情况下会初始化为第一个选项卡。如果选项卡计数为 0,则所选索引将为 -1。

选项卡标题可以由 Component 呈现。例如,以下会产生类似的结果:

 // In this case the look and feel renders the title for the tab.
 tabbedPane.addTab("Tab", myComponent);
 // In this case the custom component is responsible for rendering the
 // title of the tab.
 tabbedPane.addTab(null, myComponent);
 tabbedPane.setTabComponentAt(0, new JLabel("Tab"));
 
后者通常用于需要选项卡上的自定义组件的更复杂的用户交互。例如,您可以提供一个自定义的动画组件或一个具有用于关闭选项卡的小部件的组件。

如果您为选项卡指定组件,JTabbedPane 将不会呈现您为选项卡指定的任何文本或图标。

Note: 不要直接在选项卡组件上使用 setVisible 使其可见,而是使用 setSelectedComponentsetSelectedIndex 方法。

Warning: Swing 不是线程安全的。有关详细信息,请参阅 Swing 的线程策略

Warning: 此类的序列化对象将与未来的 Swing 版本不兼容。当前的序列化支持适用于运行相同版本 Swing 的应用程序之间的短期存储或 RMI。从 1.4 开始,对所有 JavaBeans 的长期存储的支持已添加到 java.beans 包中。请参阅 XMLEncoder

自从:
1.2
参见:
  • 字段详细信息

    • WRAP_TAB_LAYOUT

      public static final int WRAP_TAB_LAYOUT
      当所有选项卡都不适合单次运行时,用于在多次运行中包装选项卡的选项卡布局策略。
      参见:
    • SCROLL_TAB_LAYOUT

      public static final int SCROLL_TAB_LAYOUT
      选项卡布局策略,用于在一次运行中无法容纳所有选项卡时提供可用选项卡的子集。如果所有选项卡都不适合单次运行,外观将提供一种导航到隐藏选项卡的方法。
      参见:
    • tabPlacement

      protected int tabPlacement
      标签的放置位置。
      参见:
    • model

      protected SingleSelectionModel  model
      默认选择模型
    • changeListener

      protected ChangeListener  changeListener
      changeListener 是我们添加到模型中的监听器。
    • changeEvent

      protected transient ChangeEvent  changeEvent
      每个 TabPane 实例只需要一个 ChangeEvent,因为事件的唯一(只读)状态是源属性。这里产生的事件源总是“this”。
  • 构造方法详细信息

  • 方法详情

    • getUI

      public TabbedPaneUI  getUI()
      返回为该组件实现 L&F 的 UI 对象。
      重写:
      getUI 在类 JComponent
      返回:
      一个TabbedPaneUI对象
      参见:
    • setUI

      @BeanProperty (hidden =true, visualUpdate =true, description ="The UI object that implements the tabbedpane\'s LookAndFeel") public void setUI(TabbedPaneUI  ui)
      设置实现此组件的 L&F 的 UI 对象。
      参数:
      ui - 新的 UI 对象
      参见:
    • updateUI

      public void updateUI()
      将 UI 属性重置为当前外观的值。
      重写:
      updateUI 在类 JComponent
      参见:
    • getUIClassID

      @BeanProperty (bound =false) public String  getUIClassID()
      返回实现此组件的 L&F 的 UI 类的名称。
      重写:
      getUIClassID 在类 JComponent
      返回:
      字符串“TabbedPaneUI”
      参见:
    • createChangeListener

      protected ChangeListener  createChangeListener()
      想要以不同方式处理 ChangeEvents 的子类可以覆盖它以返回 ModelListener 的子类或另一个 ChangeListener 实现。
      返回:
      ChangeListener
      参见:
    • addChangeListener

      public void addChangeListener(ChangeListener  l)
      ChangeListener 添加到此选项卡窗格。
      参数:
      l - 要添加的 ChangeListener
      参见:
    • removeChangeListener

      public void removeChangeListener(ChangeListener  l)
      从此选项卡窗格中删除 ChangeListener
      参数:
      l - 要删除的 ChangeListener
      参见:
    • getChangeListeners

      @BeanProperty (bound =false) public ChangeListener [] getChangeListeners()
      返回添加到此 JTabbedPaneaddChangeListener 的所有 ChangeListener 的数组。
      返回:
      添加所有 ChangeListener 或如果未添加任何监听器,则为空数组
      自从:
      1.4
    • fireStateChanged

      protected void fireStateChanged()
      发送一个 ChangeEvent ,以这个 JTabbedPane 作为源,到每个注册的监听器。每次 JTabbedPane 中的选定索引或选定选项卡发生更改时,都会调用此方法。通常,选定的索引和选定的选项卡一起更改。但是,在某些情况下,例如选项卡添加,所选索引发生变化而同一选项卡保持选中状态。还有其他情况,例如删除所选选项卡,索引保持不变,但新选项卡移动到该索引。所有这些情况都会触发事件。
      参见:
    • getModel

      public SingleSelectionModel  getModel()
      返回与此选项卡窗格关联的模型。
      返回:
      与此选项卡窗格关联的 SingleSelectionModel
      参见:
    • setModel

      @BeanProperty (description ="The tabbedpane\'s SingleSelectionModel.") public void setModel(SingleSelectionModel  model)
      设置要与此选项卡式窗格一起使用的模型。
      参数:
      model - 要使用的模型
      参见:
    • getTabPlacement

      public int getTabPlacement()
      返回此选项卡式窗格的选项卡位置。
      返回:
      一个 int 指定选项卡的位置
      参见:
    • setTabPlacement

      @BeanProperty (preferred =true, visualUpdate =true, enumerationValues ={"JTabbedPane.TOP","JTabbedPane.LEFT","JTabbedPane.BOTTOM","JTabbedPane.RIGHT"}, description ="The tabbedpane\'s tab placement.") public void setTabPlacement(int tabPlacement)
      设置此选项卡窗格的选项卡位置。可能的值是:
      • JTabbedPane.TOP
      • JTabbedPane.BOTTOM
      • JTabbedPane.LEFT
      • JTabbedPane.RIGHT
      如果未设置,默认值为 SwingConstants.TOP
      参数:
      tabPlacement - 选项卡相对于内容的位置
      抛出:
      IllegalArgumentException - 如果选项卡放置值不是上述有效值之一
    • getTabLayoutPolicy

      public int getTabLayoutPolicy()
      当所有选项卡都不适合单次运行时,返回选项卡窗格用于布局选项卡的策略。
      返回:
      int 指定用于布局选项卡的策略
      自从:
      1.4
      参见:
    • setTabLayoutPolicy

      @BeanProperty (preferred =true, visualUpdate =true, enumerationValues ={"JTabbedPane.WRAP_TAB_LAYOUT","JTabbedPane.SCROLL_TAB_LAYOUT"}, description ="The tabbedpane\'s policy for laying out the tabs") public void setTabLayoutPolicy(int tabLayoutPolicy)
      设置当所有选项卡不适合一次运行时选项卡窗格将用于布置选项卡的策略。可能的值是:
      • JTabbedPane.WRAP_TAB_LAYOUT
      • JTabbedPane.SCROLL_TAB_LAYOUT
      如果 UI 未设置,则默认值为 JTabbedPane.WRAP_TAB_LAYOUT

      一些外观可能只支持可能的布局策略的一个子集,在这种情况下,这个属性的值可能会被忽略。

      参数:
      tabLayoutPolicy - 用于布局选项卡的策略
      抛出:
      IllegalArgumentException - 如果 layoutPolicy 值不是上述有效值之一
      自从:
      1.4
      参见:
    • getSelectedIndex

      public int getSelectedIndex()
      返回当前为此选项卡窗格选择的索引。如果当前没有选定的选项卡,则返回 -1。
      返回:
      所选选项卡的索引
      参见:
    • setSelectedIndex

      @BeanProperty (bound =false, preferred =true, description ="The tabbedpane\'s selected tab index.") public void setSelectedIndex(int index)
      为此选项卡式窗格设置选定索引。索引必须是有效的选项卡索引或 -1,这表示不应选择任何选项卡(也可以在选项卡窗格中没有选项卡时使用)。如果在选项卡窗格包含一个或多个选项卡时指定 -1 值,则结果将由实现定义。
      参数:
      index - 要选择的索引
      抛出:
      IndexOutOfBoundsException - 如果索引超出范围 (index < -1 || index >= tab count)
      参见:
    • getSelectedComponent

      public Component  getSelectedComponent()
      返回当前为此选项卡窗格选择的组件。如果当前没有选定的选项卡,则返回 null
      返回:
      与所选选项卡对应的组件
      参见:
    • setSelectedComponent

      @BeanProperty (bound =false, preferred =true, description ="The tabbedpane\'s selected component.") public void setSelectedComponent(Component  c)
      为此选项卡式窗格设置所选组件。这将自动将 selectedIndex 设置为与指定组件对应的索引。
      参数:
      c - 为此 TabbedPane 选择的 Component
      抛出:
      IllegalArgumentException - 如果在选项卡式窗格中找不到组件
      参见:
    • insertTab

      public void insertTab(String  title, Icon  icon, Component  component, String  tip, int index)
      在给定索引处为给定组件插入一个新选项卡,由给定标题和/或图标表示,其中任何一个都可以是 null
      参数:
      title - 要在选项卡上显示的标题
      icon - 要在选项卡上显示的图标
      component - 单击此选项卡时要显示的组件。
      tip - 要为此选项卡显示的工具提示
      index - 插入这个新标签的位置 (index >= 0 && index <= getTabCount())
      抛出:
      IndexOutOfBoundsException - 如果索引超出范围 (index < 0 || index > getTabCount())
      参见:
    • addTab

      public void addTab(String  title, Icon  icon, Component  component, String  tip)
      添加 componenttiptitle 和/或 icon 表示,其中任何一个都可以是 nullinsertTab 的覆盖方法。
      参数:
      title - 要在此选项卡中显示的标题
      icon - 要在此选项卡中显示的图标
      component - 单击此选项卡时要显示的组件
      tip - 要为此选项卡显示的工具提示
      参见:
    • addTab

      public void addTab(String  title, Icon  icon, Component  component)
      添加由 title 和/或 icon 表示的 component,其中任何一个都可以是 nullinsertTab 的覆盖方法。
      参数:
      title - 要在此选项卡中显示的标题
      icon - 要在此选项卡中显示的图标
      component - 单击此选项卡时要显示的组件
      参见:
    • addTab

      public void addTab(String  title, Component  component)
      添加一个 component,由 title 表示,没有图标。 insertTab 的覆盖方法。
      参数:
      title - 要在此选项卡中显示的标题
      component - 单击此选项卡时要显示的组件
      参见:
    • add

      public Component  add(Component  component)
      添加一个 component,其选项卡标题默认为组件名称,这是调用 component.getName 的结果。 insertTab 的覆盖方法。
      重写:
      add 在类 Container
      参数:
      component - 单击此选项卡时要显示的组件
      返回:
      组件
      参见:
    • add

      public Component  add(String  title, Component  component)
      添加具有指定选项卡标题的 componentinsertTab 的覆盖方法。
      重写:
      add 在类 Container
      参数:
      title - 要在此选项卡中显示的标题
      component - 单击此选项卡时要显示的组件
      返回:
      组件
      参见:
    • add

      public Component  add(Component  component, int index)
      在指定的选项卡索引处添加一个 component,选项卡标题默认为组件名称。 insertTab 的覆盖方法。
      重写:
      add 在类 Container
      参数:
      component - 单击此选项卡时要显示的组件
      index - 插入这个新标签的位置
      返回:
      组件
      参见:
    • add

      public void add(Component  component, Object  constraints)
      component 添加到选项卡式窗格。如果 constraintsStringIcon ,它将用作选项卡标题,否则组件的名称将用作选项卡标题。 insertTab 的覆盖方法。
      重写:
      add 在类 Container
      参数:
      component - 单击此选项卡时要显示的组件
      constraints - 要在选项卡中显示的对象
      参见:
    • add

      public void add(Component  component, Object  constraints, int index)
      在指定的选项卡索引处添加 component。如果 constraintsStringIcon ,它将用作选项卡标题,否则组件的名称将用作选项卡标题。 insertTab 的覆盖方法。
      重写:
      add 在类 Container
      参数:
      component - 单击此选项卡时要显示的组件
      constraints - 要在选项卡中显示的对象
      index - 插入这个新标签的位置
      参见:
    • removeTabAt

      public void removeTabAt(int index)
      删除 index 处的选项卡。删除与 index 关联的组件后,其可见性将重置为 true 以确保将其添加到其他容器时可见。
      参数:
      index - 要删除的选项卡的索引
      抛出:
      IndexOutOfBoundsException - 如果索引超出范围 (index < 0 || index >= tab count)
      参见:
    • remove

      public void remove(Component  component)
      JTabbedPane 中删除指定的 Component。如果 component 为空,则该方法不执行任何操作。
      重写:
      remove 在类 Container
      参数:
      component - 要从选项卡窗格中删除的组件
      参见:
    • remove

      public void remove(int index)
      移除指定索引对应的选项卡和组件。
      重写:
      remove 在类 Container
      参数:
      index - 要从 tabbedpane 中删除的组件的索引
      抛出:
      IndexOutOfBoundsException - 如果索引超出范围 (index < 0 || index >= tab count)
      参见:
    • removeAll

      public void removeAll()
      tabbedpane 中删除所有选项卡及其相应组件。
      重写:
      removeAll 在类 Container
      参见:
    • getTabCount

      @BeanProperty (bound =false) public int getTabCount()
      返回此 tabbedpane 中的选项卡数。
      返回:
      一个整数,指定标签页的数量
    • getTabRunCount

      @BeanProperty (bound =false) public int getTabRunCount()
      返回当前用于显示选项卡的选项卡运行数。
      返回:
      如果 tabPlacementTOPBOTTOM,则给出行数的整数;如果 tabPlacementLEFTRIGHT,则给出列数;如果此 tabbedpane 上没有设置 UI,则为 0
    • getTitleAt

      public String  getTitleAt(int index)
      返回位于 index 的选项卡标题。
      参数:
      index - 被查询项目的索引
      返回:
      index 的标题
      抛出:
      IndexOutOfBoundsException - 如果索引超出范围 (index < 0 || index >= tab count)
      参见:
    • getIconAt

      public Icon  getIconAt(int index)
      返回 index 处的选项卡图标。
      参数:
      index - 被查询项目的索引
      返回:
      index 处的图标
      抛出:
      IndexOutOfBoundsException - 如果索引超出范围 (index < 0 || index >= tab count)
      参见:
    • getDisabledIconAt

      public Icon  getDisabledIconAt(int index)
      返回 index 处的选项卡禁用图标。如果 index 处不存在选项卡禁用图标,这会将调用转发给外观,以从相应的启用图标构建适当的禁用图标。某些外观可能不会呈现禁用的图标,在这种情况下,它不会被创建。
      参数:
      index - 被查询项目的索引
      返回:
      index 处的图标
      抛出:
      IndexOutOfBoundsException - 如果索引超出范围 (index < 0 || index >= tab count)
      参见:
    • getToolTipTextAt

      public String  getToolTipTextAt(int index)
      返回位于 index 的选项卡工具提示文本。
      参数:
      index - 被查询项目的索引
      返回:
      包含位于 index 的工具提示文本的字符串
      抛出:
      IndexOutOfBoundsException - 如果索引超出范围 (index < 0 || index >= tab count)
      自从:
      1.3
      参见:
    • getBackgroundAt

      public Color  getBackgroundAt(int index)
      返回 index 处的选项卡背景颜色。
      参数:
      index - 被查询项目的索引
      返回:
      index 选项卡背景的 Color
      抛出:
      IndexOutOfBoundsException - 如果索引超出范围 (index < 0 || index >= tab count)
      参见:
    • getForegroundAt

      public Color  getForegroundAt(int index)
      返回 index 处的选项卡前景色。
      参数:
      index - 被查询项目的索引
      返回:
      index 选项卡前景的 Color
      抛出:
      IndexOutOfBoundsException - 如果索引超出范围 (index < 0 || index >= tab count)
      参见:
    • isEnabledAt

      public boolean isEnabledAt(int index)
      返回 index 处的选项卡当前是否启用。
      参数:
      index - 被查询项目的索引
      返回:
      如果 index 的选项卡已启用,则为真;否则为假
      抛出:
      IndexOutOfBoundsException - 如果索引超出范围 (index < 0 || index >= tab count)
      参见:
    • getComponentAt

      public Component  getComponentAt(int index)
      返回位于 index 的组件。
      参数:
      index - 被查询项目的索引
      返回:
      Componentindex
      抛出:
      IndexOutOfBoundsException - 如果索引超出范围 (index < 0 || index >= tab count)
      参见:
    • getMnemonicAt

      public int getMnemonicAt(int tabIndex)
      返回用于访问指定选项卡的键盘助记符。助记符是与外观的无鼠标修饰符(通常是 Alt)结合使用时将激活指定选项卡的键。
      参数:
      tabIndex - 助记符所指的选项卡的索引
      返回:
      代表助记词的键码; -1 如果没有为选项卡指定助记符
      抛出:
      IndexOutOfBoundsException - 如果索引超出范围(tabIndex < 0 || tabIndex >= 选项卡计数)
      自从:
      1.4
      参见:
    • getDisplayedMnemonicIndexAt

      public int getDisplayedMnemonicIndexAt(int tabIndex)
      返回作为索引的字符,外观应该为其提供装饰以表示助记字符。
      参数:
      tabIndex - 助记符所指的选项卡的索引
      返回:
      表示助记符的索引(如果存在);否则返回 -1
      抛出:
      IndexOutOfBoundsException - 如果索引超出范围(tabIndex < 0 || tabIndex >= 选项卡计数)
      自从:
      1.4
      参见:
    • getBoundsAt

      public Rectangle  getBoundsAt(int index)
      返回 index 处的制表符边界。如果此索引处的选项卡当前在 UI 中不可见,则返回 null 。如果此 tabbedpane 上没有设置 UI,则返回 null
      参数:
      index - 要查询的索引
      返回:
      Rectangle 包含位于 index 的制表符边界,或者 null 如果 index 的制表符当前在 UI 中不可见,或者如果在此 tabbedpane 上没有设置 UI
      抛出:
      IndexOutOfBoundsException - 如果索引超出范围 (index < 0 || index >= tab count)
    • setTitleAt

      @BeanProperty (preferred =true, visualUpdate =true, description ="The title at the specified tab index.") public void setTitleAt(int index, String  title)
      将位于 index 的标题设置为 title,可以是 null。如果指定了此选项卡的选项卡组件,则不会显示标题。如果该索引处没有选项卡,则会引发内部异常。
      参数:
      index - 应设置标题的选项卡索引
      title - 要在选项卡中显示的标题
      抛出:
      IndexOutOfBoundsException - 如果索引超出范围 (index < 0 || index >= tab count)
      参见:
    • setIconAt

      @BeanProperty (preferred =true, visualUpdate =true, description ="The icon at the specified tab index.") public void setIconAt(int index, Icon  icon)
      index 处的图标设置为 icon,可以是 null。这不会在 icon 处设置禁用图标。如果新图标不同于当前图标并且未明确设置禁用图标,则将要求 LookAndFeel 生成禁用图标。要明确设置禁用图标,请使用 setDisableIconAt() 。如果指定了此选项卡的选项卡组件,则不会显示该图标。如果该索引处没有选项卡,则会引发内部异常。
      参数:
      index - 应设置图标的选项卡索引
      icon - 要在选项卡中显示的图标
      抛出:
      IndexOutOfBoundsException - 如果索引超出范围 (index < 0 || index >= tab count)
      参见:
    • setDisabledIconAt

      @BeanProperty (preferred =true, visualUpdate =true, description ="The disabled icon at the specified tab index.") public void setDisabledIconAt(int index, Icon  disabledIcon)
      index 处的禁用图标设置为 icon,可以是 null。如果该索引处没有选项卡,则会引发内部异常。
      参数:
      index - 应该设置禁用图标的选项卡索引
      disabledIcon - 禁用时要在选项卡中显示的图标
      抛出:
      IndexOutOfBoundsException - 如果索引超出范围 (index < 0 || index >= tab count)
      参见:
    • setToolTipTextAt

      @BeanProperty (preferred =true, description ="The tooltip text at the specified tab index.") public void setToolTipTextAt(int index, String  toolTipText)
      index 处的工具提示文本设置为 toolTipText,可以是 null。如果该索引处没有选项卡,则会引发内部异常。
      参数:
      index - 应设置工具提示文本的选项卡索引
      toolTipText - 要为选项卡显示的工具提示文本
      抛出:
      IndexOutOfBoundsException - 如果索引超出范围 (index < 0 || index >= tab count)
      自从:
      1.3
      参见:
    • setBackgroundAt

      @BeanProperty (preferred =true, visualUpdate =true, description ="The background color at the specified tab index.") public void setBackgroundAt(int index, Color  background)
      index 的背景颜色设置为 background 可以是 null ,在这种情况下,选项卡的背景颜色将默认为 tabbedpane 的背景颜色。如果该索引处没有选项卡,则会引发内部异常。

      尊重此属性取决于外观和感觉,有些人可能会选择忽略它。

      参数:
      index - 应设置背景的选项卡索引
      background - 选项卡背景中显示的颜色
      抛出:
      IndexOutOfBoundsException - 如果索引超出范围 (index < 0 || index >= tab count)
      参见:
    • setForegroundAt

      @BeanProperty (preferred =true, visualUpdate =true, description ="The foreground color at the specified tab index.") public void setForegroundAt(int index, Color  foreground)
      index 的前景色设置为 foreground ,可以是 null ,在这种情况下,选项卡的前景色将默认为此 tabbedpane 的前景色。如果该索引处没有选项卡,则会引发内部异常。

      尊重此属性取决于外观和感觉,有些人可能会选择忽略它。

      参数:
      index - 应设置前景的选项卡索引
      foreground - 显示为选项卡前景的颜色
      抛出:
      IndexOutOfBoundsException - 如果索引超出范围 (index < 0 || index >= tab count)
      参见:
    • setEnabledAt

      public void setEnabledAt(int index, boolean enabled)
      设置是否启用 index 处的选项卡。如果该索引处没有选项卡,则会引发内部异常。
      参数:
      index - 应该启用/禁用的选项卡索引
      enabled - 是否应该启用选项卡
      抛出:
      IndexOutOfBoundsException - 如果索引超出范围 (index < 0 || index >= tab count)
      参见:
    • setComponentAt

      @BeanProperty (visualUpdate =true, description ="The component at the specified tab index.") public void setComponentAt(int index, Component  component)
      将位于 index 的组件设置为 component。如果该索引处没有选项卡,则会引发内部异常。
      参数:
      index - 放置此组件的选项卡索引
      component - 选项卡的组件
      抛出:
      IndexOutOfBoundsException - 如果索引超出范围 (index < 0 || index >= tab count)
      参见:
    • setDisplayedMnemonicIndexAt

      @BeanProperty (visualUpdate =true, description ="the index into the String to draw the keyboard character mnemonic at") public void setDisplayedMnemonicIndexAt(int tabIndex, int mnemonicIndex)
      提供有关应修饰文本中的哪个字符以表示助记符的外观提示。并非所有外观都支持这一点。值 -1 表示此选项卡没有助记符,或者您不希望为此选项卡显示助记符。

      this 的值随着与助记符相关的属性(例如助记符本身、文本...)的变化而更新。如果您不希望为默认字符加下划线,则只应调用此方法。例如,如果选项卡索引 3 处的文本是“Apple Price”,助记符为“p”,并且您希望修饰“P”,如“ApplePrice',则必须在调用 setMnemonicAt(3, KeyEvent.VK_P) 之后调用 setDisplayedMnemonicIndex(3, 6)

      请注意,程序员有责任确保每个选项卡都有唯一的助记符,否则可能会出现不可预测的结果。

      参数:
      tabIndex - 助记符所指的选项卡的索引
      mnemonicIndex - 索引到 String 下划线
      抛出:
      IndexOutOfBoundsException - 如果 tabIndex 超出范围 (tabIndex < 0 || tabIndex >= tab count)
      IllegalArgumentException - 如果 mnemonicIndex 是 >= 选项卡标题的长度,或者 < -1,将被抛出
      自从:
      1.4
      参见:
    • setMnemonicAt

      @BeanProperty (visualUpdate =true, description ="The keyboard mnenmonic, as a KeyEvent VK constant, for the specified tab") public void setMnemonicAt(int tabIndex, int mnemonic)
      设置用于访问指定选项卡的键盘助记符。助记符是与外观的无鼠标修饰符(通常是 Alt)结合使用时将激活指定选项卡的键。

      助记符必须对应于键盘上的单个键,并且应使用 java.awt.event.KeyEvent 中定义的 VK_XXX 键码之一或通过 java.awt.event.KeyEvent.getExtendedKeyCodeForChar 获得的扩展键码之一指定。助记符不区分大小写,因此具有相应键码的键事件将导致按钮被激活,无论是否按下 Shift 修饰符。

      这将更新指定选项卡的显示助记符属性。

      参数:
      tabIndex - 助记符所指的选项卡的索引
      mnemonic - 代表助记符的键码
      抛出:
      IndexOutOfBoundsException - 如果 tabIndex 超出范围 (tabIndex < 0 || tabIndex >= tab count)
      自从:
      1.4
      参见:
    • indexOfTab

      public int indexOfTab(String  title)
      返回具有给定 title 的第一个选项卡索引,如果没有选项卡具有此标题,则返回 -1。
      参数:
      title - 选项卡的标题
      返回:
      匹配 title 的第一个选项卡索引,如果没有选项卡具有此标题,则为 -1
    • indexOfTab

      public int indexOfTab(Icon  icon)
      返回具有给定 icon 的第一个选项卡索引,如果没有选项卡具有此图标,则返回 -1。
      参数:
      icon - 选项卡的图标
      返回:
      匹配 icon 的第一个选项卡索引,如果没有选项卡具有此图标,则为 -1
    • indexOfComponent

      public int indexOfComponent(Component  component)
      返回指定组件的选项卡索引。如果此组件没有选项卡,则返回 -1。
      参数:
      component - 选项卡的组件
      返回:
      匹配此组件的第一个选项卡,如果此组件没有选项卡则为 -1
    • indexAtLocation

      public int indexAtLocation(int x, int y)
      返回其边界与指定位置相交的选项卡对应的选项卡索引。如果没有制表符与该位置相交,则返回 -1。
      参数:
      x - 相对于此选项卡窗格的 x 位置
      y - 相对于此选项卡窗格的 y 位置
      返回:
      与位置相交的选项卡索引,如果没有选项卡与该位置相交,则为 -1
      自从:
      1.4
    • getToolTipText

      public String  getToolTipText(MouseEvent  event)
      返回由鼠标事件位置确定的组件的工具提示文本。
      重写:
      getToolTipText 在类 JComponent
      参数:
      event - MouseEvent 告诉光标在哪里徘徊
      返回:
      包含工具提示文本的 String
    • paramString

      protected String  paramString()
      返回此 JTabbedPane 的字符串表示形式。此方法仅用于调试目的,返回字符串的内容和格式可能因实现而异。返回的字符串可能为空,但可能不是 null
      重写:
      paramString 在类 JComponent
      返回:
      此 JTabbedPane 的字符串表示形式。
    • getAccessibleContext

      @BeanProperty (bound =false) public AccessibleContext  getAccessibleContext()
      获取与此 JTabbedPane 关联的 AccessibleContext。对于选项卡式窗格,AccessibleContext 采用 AccessibleJTabbedPane 的形式。如有必要,将创建一个新的 AccessibleJTabbedPane 实例。
      指定者:
      getAccessibleContext 在接口 Accessible
      重写:
      getAccessibleContext 在类 Component
      返回:
      作为此 JTabbedPane 的 AccessibleContext 的 AccessibleJTabbedPane
    • setTabComponentAt

      @BeanProperty (preferred =true, visualUpdate =true, description ="The tab component at the specified tab index.") public void setTabComponentAt(int index, Component  component)
      设置负责呈现指定选项卡标题的组件。空值意味着 JTabbedPane 将呈现指定选项卡的标题和/或图标。非空值意味着组件将呈现标题,JTabbedPane 将不呈现标题和/或图标。

      注意:该组件不能是开发人员已经添加到选项卡式窗格中的组件。

      参数:
      index - 应设置组件的选项卡索引
      component - 为指定选项卡呈现标题的组件
      抛出:
      IndexOutOfBoundsException - 如果索引超出范围 (index < 0 || index >= tab count)
      IllegalArgumentException - 如果组件已经添加到这个 JTabbedPane
      自从:
      1.6
      参见:
    • getTabComponentAt

      public Component  getTabComponentAt(int index)
      返回位于 index 的选项卡组件。
      参数:
      index - 被查询项目的索引
      返回:
      index 的选项卡组件
      抛出:
      IndexOutOfBoundsException - 如果索引超出范围 (index < 0 || index >= tab count)
      自从:
      1.6
      参见:
    • indexOfTabComponent

      public int indexOfTabComponent(Component  tabComponent)
      返回指定选项卡组件的选项卡索引。如果此选项卡组件没有选项卡,则返回 -1。
      参数:
      tabComponent - 选项卡的选项卡组件
      返回:
      与此选项卡组件匹配的第一个选项卡,如果此选项卡组件没有选项卡,则为 -1
      自从:
      1.6
      参见: