e833. 获得JTabbedPane中的卡片
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中的卡片的更多相关文章
- e839. 使JTabbedPane中的卡片可滚动
By default, all the tabs in a tabbed pane are displayed. When the tabs are wider than the width of t ...
- e840. 监听JTabbedPane中选中卡片的改变
A tabbed pane fires a change event whenever the selected tab is changed either by the user or progra ...
- e838. 使JTabbedPane中的卡片能用按键的方式选取
Setting a mnemonic on a tab allows the tab to be selected with a keystroke. For example, if the mnem ...
- e832. 从JTabbedPane中移动卡片
To move a tab, it must first be removed and then reinserted into the tabbed pane as a new tab. Unfor ...
- e835. 使JTabbedPane中的卡片生效和失效
By default, all new tabs are enabled, which means the user can select them. A tab can be disabled to ...
- 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 ...
- e837. 设置JTabbedPane中卡片的颜色
// Create a tabbed pane JTabbedPane pane = new JTabbedPane(); // Set the text color for all tabs pan ...
- e834. 设置JTabbedPane中卡片的位置
The tabs of a tabbed pane can be placed on one of the four edges of its container. By default, when ...
- e831. 从JTabbedPane中删除一个卡片
// To create a tabbed pane, see e828 创建JTabbedPane // Remove the last tab pane.remove(pane.getTabCou ...
随机推荐
- MySQL开发索引创建规范
1. [强制]业务上具有唯一特性的字段,即使是多个字段的组合,也必须建成唯一索引. 说明:不要以为唯一索引影响了insert速度,这个速度损耗可以忽略,但提高查找速度是明显的:另外,即使在应用层做了非 ...
- numpy数组-截取部分
import numpy as np a = np.array([1,2,3,4,5]) slice = a[:3] slice[0] = 100 print(a) # 结果 [100,2,3,4,5 ...
- linux命令(48):打乱一个文本文件的所有行
如果用python读进内存再打乱的思路,如果大文件的话,就比较麻烦了 网上找到一个简单的方法,shuf: $ shuf --help 用法: shuf [选项]... [文件] 或者: shuf -e ...
- Java 编程下简介 Class 与类加载
即使有一个类并对它一无所知,但其实它本身就包含了许多信息,Java 在需要使用到某个类时才会将类加载,并在 JVM 中以一个 java.lang.Class 的实例存在.从 Calss 实例开始,可以 ...
- webpack打包调试react并使用babel编译jsx配置方法
http://lxj8749.iteye.com/blog/2287074 ********************************************** 安装webpack npm i ...
- html5 canvas 画图移动端出现锯齿毛边的解决方法
使用HTML5的canvas元素画出来的.在移动端手机上测试都发现画图有一点锯齿问题 出现这个问题的原因应该是手机的宽是720像素的, 而这个canvas是按照小于720像素画出来的, 所以在720像 ...
- Python之Cookielib
cookielib模块的主要作用是提供可存储cookie的对象,以便于与urllib2模块配合使用来访问Internet资源.Cookielib模块非常强大,我们可以利用本模块的CookieJar类的 ...
- Python3求笛卡尔积的两种方法
[本文出自天外归云的博客园] 电影异次元杀阵三部曲中密室线索反复出现笛卡尔积的运用.百度百科: 笛卡尔乘积是指在数学中,两个集合X和Y的笛卡尓积(Cartesian product),又称直积,表示为 ...
- Python3下requests库发送multipart/form-data类型请求
[本文出自天外归云的博客园] 要模拟multipart/form-data类型请求,可以用python3的requests库完成.代码示例如下: #请求的接口url url = "url&q ...
- Python通过ssh连接服务器并执行命令
[本文出自天外归云的博客园] 脚本示例如下: # coding:utf-8 import time,paramiko,re,StringIO def exec_shell(command): ''' ...