This example retrieves all the tabs in a tabbed pane:

    // To create a tabbed pane, see e828 创建JTabbedPane

    // Get number of tabs
int count = pane.getTabCount(); // Get the properties of each tab
for (int i=0; i<count; i++) {
// Get label
String label = pane.getTitleAt(i); // Get icon
Icon icon = pane.getIconAt(i); // Get tool tip
String tooltip = pane.getToolTipTextAt(i); // Is enabled?
boolean enabled = pane.isEnabledAt(i); // Get mnemonic
int keycode = pane.getMnemonicAt(i); // Get component associated with tab
Component comp = pane.getComponentAt(i);
}

Most of the methods that allow the properties of a tab to be changed require the index of the tab. The index of a tab can change as tabs are added, removed, or moved. Here are three ways to retrieve the index of a tab when needed.

    // Get the index of the first tab that matches a label
String label = "Tab Label";
int index = pane.indexOfTab(label); // Get the index of the first tab that matches an icon; the supplied
// icon must be the same instance that was used to create the tab
index = pane.indexOfTab(icon); // Get the index of the tab by matching the child component; the supplied
// component must be the same instance that was used to create the tab
index = pane.indexOfComponent(component); if (index < 0) {
// The tab could not be found
}
Related Examples

e833. 获得JTabbedPane中的卡片的更多相关文章

  1. e839. 使JTabbedPane中的卡片可滚动

    By default, all the tabs in a tabbed pane are displayed. When the tabs are wider than the width of t ...

  2. e840. 监听JTabbedPane中选中卡片的改变

    A tabbed pane fires a change event whenever the selected tab is changed either by the user or progra ...

  3. e838. 使JTabbedPane中的卡片能用按键的方式选取

    Setting a mnemonic on a tab allows the tab to be selected with a keystroke. For example, if the mnem ...

  4. e832. 从JTabbedPane中移动卡片

    To move a tab, it must first be removed and then reinserted into the tabbed pane as a new tab. Unfor ...

  5. e835. 使JTabbedPane中的卡片生效和失效

    By default, all new tabs are enabled, which means the user can select them. A tab can be disabled to ...

  6. e836. 设置JTabbedPane中卡片的提示语

    There are two ways to set a tool tip on a tab. The first is to specify it when the tab is created; t ...

  7. e837. 设置JTabbedPane中卡片的颜色

    // Create a tabbed pane JTabbedPane pane = new JTabbedPane(); // Set the text color for all tabs pan ...

  8. e834. 设置JTabbedPane中卡片的位置

    The tabs of a tabbed pane can be placed on one of the four edges of its container. By default, when ...

  9. e831. 从JTabbedPane中删除一个卡片

    // To create a tabbed pane, see e828 创建JTabbedPane // Remove the last tab pane.remove(pane.getTabCou ...

随机推荐

  1. numpy数组-标准化数据

    标准化数据的公式: (数据值 - 平均数) / 标准差 import numpy as np employment = np.array([ 55.70000076, 51.40000153, 50. ...

  2. 每日英语:Apple Unveils New iPads

    Apple Inc. 's answer to the increasingly cutthroat tablet-computer market: more product choices and ...

  3. 【linux排错】"error while loading shared libraries: xxx.so.x" 错误的原因和解决办法

    一般我们在Linux下执行某些外部程序的时候可能会提示找不到共享库的错误, 比如: lcw: error : cannot open shared object file: No such file ...

  4. Docker 入门(Mac环境)- part 5 stacks

    part-5 stacks 简介 stack就是栈,栈的结构是什么样的呢?一层一层是紧挨着的,然后互相依赖,不能说中间少了一个.这样说就很明白了,栈实际上在docker中就相当于多个互相依赖的组件,共 ...

  5. js中取小数整数部分函数;取小数部分

    1.丢弃小数部分,保留整数部分 parseInt(23.56); 结果:23 2.向上取整,有小数就整数部分加1 Math.ceil(23.56) 结果:24 3,四舍五入. Math.round(2 ...

  6. LeetCode: Pascal's Triangle II 解题报告

    Pascal's Triangle II Total Accepted: 19384 Total Submissions: 63446 My Submissions Question Solution ...

  7. zoj 3762(求三角形的最大高)

    给出n个点,要你找到一个三角形,它的高是最长的. 思路:暴力超时了,是用先找出n个点与其他点的最长边,再枚举顶点过的.......具体证明不知道..... #include<algorithm& ...

  8. javascript中json对象长度

    JSON中无法使用length去获取长度,length只针对数组对象适用: var data={"showdata":{"中国人民大学":{"2013 ...

  9. C#学习笔记(25)——用刻盘器批量从U盘删除添加文件

    说明(2017-11-17 14:46:05): 1. 因为经常要从U盘里面删除版本,然后添加版本,每次都要几个人手动复制粘贴,费时费力,就花了一下午时间写了个程序,自动删除和添加版本. 2. Dri ...

  10. [转]java中通过request获取路径中的不同信息

    原文地址:http://blog.csdn.net/lv_shijun/article/details/40819859 aa为工程中的项目名 bb为webRoot下的文件夹 1.request.ge ...