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. 实例分析JVM安全体系:双亲委派、命名空间、保护域、策略

    在了解双亲委派模型之前,先了解一下类加载器的概念: 类加载器的作用就是将真实的class文件根据位置将该Java类的字节码装入内存,并生成对应的Class对象.用户可以通过继承ClassLoader和 ...

  2. (原创)c++11改进我们的模式之改进表驱动模式

    所谓表驱动法(Table-Driven Approach),简单讲是指用查表的方法获取值.表驱动是将一些通过较为复杂逻辑语句来得到数据信息的方式,通过查询表的方式来实现,将数据信息存放在表里.对于消除 ...

  3. Python Pycharm连接Ubantu Python环境

    由于我习惯在window下开发,但是代码环境布局在Ubantu.使用Python,为了方便程序的调试,尝试在Windows下的Pycharm远程连接到Ubantu虚拟机下的Python环境. 1.准备 ...

  4. 【转】(六)unity4.6Ugui中文教程文档-------概要-UGUI Animation Integration

    原创至上,移步请戳:(六)unity4.6Ugui中文教程文档-------概要-UGUI Animation Integration 5.Animation Integration(动画集成) 动画 ...

  5. 旧的flex

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  6. 将String转换成InputStream

    String   str   =   "";//add   your   string   contentInputStream   inputStream   =   new   ...

  7. pual_bot 天气插件编写

    最近在玩pual_bot,感觉很不错,最近天气插件失效了,就结合百度api重新写了一个,也提交了. https://github.com/coldnight/pual_bot #!/usr/bin/e ...

  8. 把git上面的scala工程转为eclipse工程

    1,安装sbt工具,url:https://www.cnblogs.com/zeling/p/8494828.html 2,把插件添加到plugins.sbt文件中: addSbtPlugin(&qu ...

  9. eclipse mars 4.5.1 自定义工具栏

    window>>perspective>>Customize Perspective

  10. docker探索-Docker 1.13 编排能力进化(十三)

     简介  docker stack deploy和docker-compose up,这两个命令都是操作compose的yml文件的,有什么区别?想知道这个问题,看下面文章 https://yq.al ...