- 所有已实现的接口:
ImageObserver,MenuContainer,Serializable,Accessible,SwingConstants
使用 addTab 和 insertTab 方法将选项卡/组件添加到 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 使其可见,而是使用 setSelectedComponent 或 setSelectedIndex 方法。
Warning: Swing 不是线程安全的。有关详细信息,请参阅 Swing 的线程策略。
Warning: 此类的序列化对象将与未来的 Swing 版本不兼容。当前的序列化支持适用于运行相同版本 Swing 的应用程序之间的短期存储或 RMI。从 1.4 开始,对所有 JavaBeans 的长期存储的支持已添加到 java.beans 包中。请参阅 XMLEncoder 。
- 自从:
- 1.2
- 参见:
-
内部类总结
内部类修饰符和类型类描述protected class此类实现了对JTabbedPane类的辅助功能支持。protected class我们将ModelChanged事件传递给使用选项卡窗格(而不是模型本身)作为事件源的监听器。在类 javax.swing.JComponent 中声明的嵌套类/接口
JComponent.AccessibleJComponent在类 java.awt.Container 中声明的嵌套类/接口
Container.AccessibleAWTContainer -
字段摘要
字段修饰符和类型Field描述protected ChangeEvent每个TabPane实例只需要一个ChangeEvent,因为事件的唯一(只读)状态是源属性。protected ChangeListenerchangeListener是我们添加到模型中的监听器。protected SingleSelectionModel默认选择模型static final int选项卡布局策略,用于在一次运行中无法容纳所有选项卡时提供可用选项卡的子集。protected int标签的放置位置。static final int当所有选项卡都不适合单次运行时,用于在多次运行中包装选项卡的选项卡布局策略。在类 javax.swing.JComponent 中声明的字段
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW在类 java.awt.Component 中声明的字段
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT在接口 java.awt.image.ImageObserver 中声明的字段
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH在接口 javax.swing.SwingConstants 中声明的字段
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST -
构造方法总结
构造方法构造方法描述创建一个空的TabbedPane,其默认制表符位置为JTabbedPane.TOP。JTabbedPane(int tabPlacement) 创建一个空的TabbedPane,其指定的制表符位置为:JTabbedPane.TOP、JTabbedPane.BOTTOM、JTabbedPane.LEFT或JTabbedPane.RIGHT。JTabbedPane(int tabPlacement, int tabLayoutPolicy) 使用指定的选项卡放置和选项卡布局策略创建一个空的TabbedPane。 -
方法总结
修饰符和类型方法描述添加一个component,其选项卡标题默认为组件名称,这是调用component.getName的结果。在指定的选项卡索引处添加一个component,选项卡标题默认为组件名称。void将component添加到选项卡式窗格。void在指定的选项卡索引处添加component。添加具有指定选项卡标题的component。void将ChangeListener添加到此选项卡窗格。void添加一个component,由title表示,没有图标。void添加由title和/或icon表示的component,其中任何一个都可以是null。void添加component和tip由title和/或icon表示,其中任何一个都可以是null。protected ChangeListener想要以不同方式处理ChangeEvents的子类可以覆盖它以返回ModelListener的子类或另一个ChangeListener实现。protected void发送一个ChangeEvent,以这个JTabbedPane作为源,到每个注册的监听器。获取与此 JTabbedPane 关联的 AccessibleContext。getBackgroundAt(int index) 返回index处的选项卡背景颜色。getBoundsAt(int index) 返回index处的制表符边界。返回添加到此JTabbedPane和addChangeListener的所有ChangeListener的数组。getComponentAt(int index) 返回位于index的组件。getDisabledIconAt(int index) 返回index处的选项卡禁用图标。intgetDisplayedMnemonicIndexAt(int tabIndex) 返回作为索引的字符,外观应该为其提供装饰以表示助记字符。getForegroundAt(int index) 返回index处的选项卡前景色。getIconAt(int index) 返回index处的选项卡图标。intgetMnemonicAt(int tabIndex) 返回用于访问指定选项卡的键盘助记符。getModel()返回与此选项卡窗格关联的模型。返回当前为此选项卡窗格选择的组件。int返回当前为此选项卡窗格选择的索引。getTabComponentAt(int index) 返回位于index的选项卡组件。int返回此tabbedpane中的选项卡数。int当所有选项卡都不适合单次运行时,返回选项卡窗格用于布局选项卡的策略。int返回此选项卡式窗格的选项卡位置。int返回当前用于显示选项卡的选项卡运行数。getTitleAt(int index) 返回位于index的选项卡标题。getToolTipText(MouseEvent event) 返回由鼠标事件位置确定的组件的工具提示文本。getToolTipTextAt(int index) 返回位于index的选项卡工具提示文本。getUI()返回为该组件实现 L&F 的 UI 对象。返回实现此组件的 L&F 的 UI 类的名称。intindexAtLocation(int x, int y) 返回其边界与指定位置相交的选项卡对应的选项卡索引。intindexOfComponent(Component component) 返回指定组件的选项卡索引。intindexOfTab(String title) 返回具有给定title的第一个选项卡索引,如果没有选项卡具有此标题,则返回 -1。intindexOfTab(Icon icon) 返回具有给定icon的第一个选项卡索引,如果没有选项卡具有此图标,则返回 -1。intindexOfTabComponent(Component tabComponent) 返回指定选项卡组件的选项卡索引。void在给定索引处为给定组件插入一个新选项卡,由给定标题和/或图标表示,其中任何一个都可以是null。booleanisEnabledAt(int index) 返回index处的选项卡当前是否启用。protected String返回此JTabbedPane的字符串表示形式voidremove(int index) 移除指定索引对应的选项卡和组件。void从JTabbedPane中删除指定的Component。void从tabbedpane中删除所有选项卡及其相应组件。void从此选项卡窗格中删除ChangeListener。voidremoveTabAt(int index) 删除index处的选项卡。voidsetBackgroundAt(int index, Color background) 将index的背景颜色设置为background可以是null,在这种情况下,选项卡的背景颜色将默认为tabbedpane的背景颜色。voidsetComponentAt(int index, Component component) 将位于index的组件设置为component。voidsetDisabledIconAt(int index, Icon disabledIcon) 将index处的禁用图标设置为icon,可以是null。voidsetDisplayedMnemonicIndexAt(int tabIndex, int mnemonicIndex) 提供有关应修饰文本中的哪个字符以表示助记符的外观提示。voidsetEnabledAt(int index, boolean enabled) 设置是否启用index处的选项卡。voidsetForegroundAt(int index, Color foreground) 将index的前景色设置为foreground,可以是null,在这种情况下,选项卡的前景色将默认为此tabbedpane的前景色。void将index处的图标设置为icon,可以是null。voidsetMnemonicAt(int tabIndex, int mnemonic) 设置用于访问指定选项卡的键盘助记符。voidsetModel(SingleSelectionModel model) 设置要与此选项卡式窗格一起使用的模型。void为此选项卡式窗格设置所选组件。voidsetSelectedIndex(int index) 为此选项卡式窗格设置选定索引。voidsetTabComponentAt(int index, Component component) 设置负责呈现指定选项卡标题的组件。voidsetTabLayoutPolicy(int tabLayoutPolicy) 设置当所有选项卡不适合一次运行时选项卡窗格将用于布置选项卡的策略。voidsetTabPlacement(int tabPlacement) 设置此选项卡窗格的选项卡位置。voidsetTitleAt(int index, String title) 将位于index的标题设置为title,可以是null。voidsetToolTipTextAt(int index, String toolTipText) 将index处的工具提示文本设置为toolTipText,可以是null。voidsetUI(TabbedPaneUI ui) 设置实现此组件的 L&F 的 UI 对象。voidupdateUI()将 UI 属性重置为当前外观的值。在类 javax.swing.JComponent 中声明的方法
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update在类 java.awt.Container 中声明的方法
addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree在类 java.awt.Component 中声明的方法
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
字段详细信息
-
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
默认选择模型 -
changeListener
changeListener是我们添加到模型中的监听器。 -
changeEvent
每个TabPane实例只需要一个ChangeEvent,因为事件的唯一(只读)状态是源属性。这里产生的事件源总是“this”。
-
-
构造方法详细信息
-
JTabbedPane
public JTabbedPane()创建一个空的TabbedPane,其默认制表符位置为JTabbedPane.TOP。- 参见:
-
JTabbedPane
public JTabbedPane(int tabPlacement) 创建一个空的TabbedPane,其指定的制表符位置为:JTabbedPane.TOP、JTabbedPane.BOTTOM、JTabbedPane.LEFT或JTabbedPane.RIGHT。- 参数:
tabPlacement- 选项卡相对于内容的位置- 参见:
-
JTabbedPane
public JTabbedPane(int tabPlacement, int tabLayoutPolicy) 使用指定的选项卡放置和选项卡布局策略创建一个空的TabbedPane。选项卡位置可以是:JTabbedPane.TOP、JTabbedPane.BOTTOM、JTabbedPane.LEFT或JTabbedPane.RIGHT。选项卡布局策略可以是:JTabbedPane.WRAP_TAB_LAYOUT或JTabbedPane.SCROLL_TAB_LAYOUT。- 参数:
tabPlacement- 选项卡相对于内容的位置tabLayoutPolicy- 当所有选项卡都不适合一次运行时布局选项卡的策略- 抛出:
IllegalArgumentException- 如果选项卡放置或选项卡布局策略不是上述支持的值之一- 自从:
- 1.4
- 参见:
-
-
方法详情
-
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
返回实现此组件的 L&F 的 UI 类的名称。- 重写:
getUIClassID在类JComponent中- 返回:
- 字符串“TabbedPaneUI”
- 参见:
-
createChangeListener
想要以不同方式处理ChangeEvents的子类可以覆盖它以返回ModelListener的子类或另一个ChangeListener实现。- 返回:
ChangeListener- 参见:
-
addChangeListener
将ChangeListener添加到此选项卡窗格。- 参数:
l- 要添加的ChangeListener- 参见:
-
removeChangeListener
从此选项卡窗格中删除ChangeListener。- 参数:
l- 要删除的ChangeListener- 参见:
-
getChangeListeners
返回添加到此JTabbedPane和addChangeListener的所有ChangeListener的数组。- 返回:
-
添加所有
ChangeListener或如果未添加任何监听器,则为空数组 - 自从:
- 1.4
-
fireStateChanged
protected void fireStateChanged()发送一个ChangeEvent,以这个JTabbedPane作为源,到每个注册的监听器。每次JTabbedPane中的选定索引或选定选项卡发生更改时,都会调用此方法。通常,选定的索引和选定的选项卡一起更改。但是,在某些情况下,例如选项卡添加,所选索引发生变化而同一选项卡保持选中状态。还有其他情况,例如删除所选选项卡,索引保持不变,但新选项卡移动到该索引。所有这些情况都会触发事件。- 参见:
-
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.TOPJTabbedPane.BOTTOMJTabbedPane.LEFTJTabbedPane.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_LAYOUTJTabbedPane.SCROLL_TAB_LAYOUT
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
返回当前为此选项卡窗格选择的组件。如果当前没有选定的选项卡,则返回null。- 返回:
- 与所选选项卡对应的组件
- 参见:
-
setSelectedComponent
@BeanProperty (bound =false, preferred =true, description ="The tabbedpane\'s selected component.") public void setSelectedComponent(Component c) 为此选项卡式窗格设置所选组件。这将自动将selectedIndex设置为与指定组件对应的索引。- 参数:
c- 为此TabbedPane选择的Component- 抛出:
IllegalArgumentException- 如果在选项卡式窗格中找不到组件- 参见:
-
insertTab
在给定索引处为给定组件插入一个新选项卡,由给定标题和/或图标表示,其中任何一个都可以是null。- 参数:
title- 要在选项卡上显示的标题icon- 要在选项卡上显示的图标component- 单击此选项卡时要显示的组件。tip- 要为此选项卡显示的工具提示index- 插入这个新标签的位置(index >= 0 && index <= getTabCount())- 抛出:
IndexOutOfBoundsException- 如果索引超出范围(index < 0 || index > getTabCount())- 参见:
-
addTab
添加component和tip由title和/或icon表示,其中任何一个都可以是null。insertTab的覆盖方法。- 参数:
title- 要在此选项卡中显示的标题icon- 要在此选项卡中显示的图标component- 单击此选项卡时要显示的组件tip- 要为此选项卡显示的工具提示- 参见:
-
addTab
添加由title和/或icon表示的component,其中任何一个都可以是null。insertTab的覆盖方法。- 参数:
title- 要在此选项卡中显示的标题icon- 要在此选项卡中显示的图标component- 单击此选项卡时要显示的组件- 参见:
-
addTab
添加一个component,由title表示,没有图标。insertTab的覆盖方法。- 参数:
title- 要在此选项卡中显示的标题component- 单击此选项卡时要显示的组件- 参见:
-
add
添加一个component,其选项卡标题默认为组件名称,这是调用component.getName的结果。insertTab的覆盖方法。 -
add
添加具有指定选项卡标题的component。insertTab的覆盖方法。 -
add
在指定的选项卡索引处添加一个component,选项卡标题默认为组件名称。insertTab的覆盖方法。 -
add
将component添加到选项卡式窗格。如果constraints是String或Icon,它将用作选项卡标题,否则组件的名称将用作选项卡标题。insertTab的覆盖方法。 -
add
在指定的选项卡索引处添加component。如果constraints是String或Icon,它将用作选项卡标题,否则组件的名称将用作选项卡标题。insertTab的覆盖方法。 -
removeTabAt
public void removeTabAt(int index) 删除index处的选项卡。删除与index关联的组件后,其可见性将重置为 true 以确保将其添加到其他容器时可见。- 参数:
index- 要删除的选项卡的索引- 抛出:
IndexOutOfBoundsException- 如果索引超出范围(index < 0 || index >= tab count)- 参见:
-
remove
从JTabbedPane中删除指定的Component。如果component为空,则该方法不执行任何操作。 -
remove
public void remove(int index) 移除指定索引对应的选项卡和组件。- 重写:
remove在类Container中- 参数:
index- 要从tabbedpane中删除的组件的索引- 抛出:
IndexOutOfBoundsException- 如果索引超出范围(index < 0 || index >= tab count)- 参见:
-
removeAll
public void removeAll()从tabbedpane中删除所有选项卡及其相应组件。 -
getTabCount
返回此tabbedpane中的选项卡数。- 返回:
- 一个整数,指定标签页的数量
-
getTabRunCount
返回当前用于显示选项卡的选项卡运行数。- 返回:
-
如果
tabPlacement是TOP或BOTTOM,则给出行数的整数;如果tabPlacement是LEFT或RIGHT,则给出列数;如果此tabbedpane上没有设置 UI,则为 0
-
getTitleAt
返回位于index的选项卡标题。- 参数:
index- 被查询项目的索引- 返回:
index的标题- 抛出:
IndexOutOfBoundsException- 如果索引超出范围(index < 0 || index >= tab count)- 参见:
-
getIconAt
返回index处的选项卡图标。- 参数:
index- 被查询项目的索引- 返回:
index处的图标- 抛出:
IndexOutOfBoundsException- 如果索引超出范围(index < 0 || index >= tab count)- 参见:
-
getDisabledIconAt
返回index处的选项卡禁用图标。如果index处不存在选项卡禁用图标,这会将调用转发给外观,以从相应的启用图标构建适当的禁用图标。某些外观可能不会呈现禁用的图标,在这种情况下,它不会被创建。- 参数:
index- 被查询项目的索引- 返回:
index处的图标- 抛出:
IndexOutOfBoundsException- 如果索引超出范围(index < 0 || index >= tab count)- 参见:
-
getToolTipTextAt
返回位于index的选项卡工具提示文本。- 参数:
index- 被查询项目的索引- 返回:
-
包含位于
index的工具提示文本的字符串 - 抛出:
IndexOutOfBoundsException- 如果索引超出范围(index < 0 || index >= tab count)- 自从:
- 1.3
- 参见:
-
getBackgroundAt
返回index处的选项卡背景颜色。- 参数:
index- 被查询项目的索引- 返回:
index选项卡背景的Color- 抛出:
IndexOutOfBoundsException- 如果索引超出范围(index < 0 || index >= tab count)- 参见:
-
getForegroundAt
返回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
返回位于index的组件。- 参数:
index- 被查询项目的索引- 返回:
Component在index- 抛出:
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
返回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
返回具有给定title的第一个选项卡索引,如果没有选项卡具有此标题,则返回 -1。- 参数:
title- 选项卡的标题- 返回:
-
匹配
title的第一个选项卡索引,如果没有选项卡具有此标题,则为 -1
-
indexOfTab
返回具有给定icon的第一个选项卡索引,如果没有选项卡具有此图标,则返回 -1。- 参数:
icon- 选项卡的图标- 返回:
-
匹配
icon的第一个选项卡索引,如果没有选项卡具有此图标,则为 -1
-
indexOfComponent
返回指定组件的选项卡索引。如果此组件没有选项卡,则返回 -1。- 参数:
component- 选项卡的组件- 返回:
- 匹配此组件的第一个选项卡,如果此组件没有选项卡则为 -1
-
indexAtLocation
public int indexAtLocation(int x, int y) 返回其边界与指定位置相交的选项卡对应的选项卡索引。如果没有制表符与该位置相交,则返回 -1。- 参数:
x- 相对于此选项卡窗格的 x 位置y- 相对于此选项卡窗格的 y 位置- 返回:
- 与位置相交的选项卡索引,如果没有选项卡与该位置相交,则为 -1
- 自从:
- 1.4
-
getToolTipText
返回由鼠标事件位置确定的组件的工具提示文本。- 重写:
getToolTipText在类JComponent中- 参数:
event-MouseEvent告诉光标在哪里徘徊- 返回:
-
包含工具提示文本的
String
-
paramString
返回此JTabbedPane的字符串表示形式。此方法仅用于调试目的,返回字符串的内容和格式可能因实现而异。返回的字符串可能为空,但可能不是null。- 重写:
paramString在类JComponent中- 返回:
- 此 JTabbedPane 的字符串表示形式。
-
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
返回位于index的选项卡组件。- 参数:
index- 被查询项目的索引- 返回:
index的选项卡组件- 抛出:
IndexOutOfBoundsException- 如果索引超出范围(index < 0 || index >= tab count)- 自从:
- 1.6
- 参见:
-
indexOfTabComponent
返回指定选项卡组件的选项卡索引。如果此选项卡组件没有选项卡,则返回 -1。- 参数:
tabComponent- 选项卡的选项卡组件- 返回:
- 与此选项卡组件匹配的第一个选项卡,如果此选项卡组件没有选项卡,则为 -1
- 自从:
- 1.6
- 参见:
-