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. c#,asp.net 开发 app 学习资料整理

    VS2015 Apache Cordova第一个Android和IOS应用 http://www.cnblogs.com/aehyok/p/4116410.html PhoneGap:免费开源的 HT ...

  2. C++11 override和final

    30多年来,C++一直没有继承控制关键字.最起码这是不容易的,禁止一个类的进一步衍生是可能的但也很棘手.为避免用户在派生类中重载一个虚函数,你不得不向后考虑. C++ 11添加了两个继承控制关键字:o ...

  3. linux命令(39):shell 打印偶数行,奇数行 ,行号

    awk 命令: 1. 打印行号和内容: awk '{print NR":"$0}' 2. 输出:偶数行和奇数行到文件 awk '{print $0.txt > NR%2.tx ...

  4. 使用终端执行.app程序 for mac

    背景:打开Eclipse闪退,需要查看错误日志 问题:使用Terminal执行 ./Eclipse.app时,提示“no such file or directory” 解决方案:执行./Applic ...

  5. [翻译] Dremel made simple with Parquet

    首先自己的 blog 好久没有写技术相关的东西了,今天又动笔了,好高兴!然后转载请注明出处.最后开始正题: 原文:Dremel made simple with Parquet | Twitter E ...

  6. js设置滚动条定位到所属容器的最底部

    $('.help-gundongtiao').scrollTop($('.help-gundongtiao')[0].scrollHeight);

  7. 【转】一件有趣的事:我用 Python 爬了爬自己的微信朋友

    偶然了解到 Python 里的 itchat 包,它已经完成了 wechat 的个人账号 API 接口,使爬取个人微信信息更加方便. 于是乎玩心一起,打算爬一下自己的微信. 步骤核心: 网页启动not ...

  8. sscanf函数——强大的C语言库函数

    这个函数真的很强大,这篇随笔也将一直更新一些总结,直到涵盖大多数应用: eg1: 今天公司项目中从云端获取了一段字符串---"+CBC: 0,90,4090" 我想获取其中的数字0 ...

  9. pthon 批量压缩当前目录,子目录下图片

    需求 经常可能有需要压缩图片的需求. 但是一些批量处理图片的软件又仅仅支持压缩一个目录下的图片, 所以写下了这个图片处理程序: 需要安装: python 2.x Image模块 特点: 压缩当前目录, ...

  10. php设计模式总结-单件模式

    一.单件模式 英文叫做sington.其他语言中有叫做单例模式,其实都是一样的道理.保证只会出现单个实例,所以是单例.翻译成单件,永远只会产生一件,呵呵. 还有翻译成单元素模式.其实关键是看这个英文比 ...