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 ...
随机推荐
- App开放接口API安全性 — Token签名sign的设计与实现
在app开放接口API的设计中,避免不了的就是安全性问题. 一.https协议 对于一些敏感的API接口,需要使用https协议. https是在http超文本传输协议加入SSL层,它在网络间通信是加 ...
- (原创)sqlite封装库SmartDB1.3发布
最近终于稍微有点空对SmartDB进行升级了,SmartDB1.3比之前的版本做了简化,增强了易用性和灵活性. SmartDB对sqlite做了一层封装,屏蔽了诸多细节,使得我们使用起来很方便.在注重 ...
- 解决IntelliJ IDEA控制台乱码问题[包含程序运行时的log4j日志以及tomcat日志乱码]
这里使用的IntelliJ IDEA版本为[IntelliJ IDEA 14.1.4]: 一.控制台打印的程序运行时的log4j日志中包含中文乱码 在IDEA安装目录的bin目录下找到名为" ...
- 关于electron的跨域问题,有本地的图片的地址,访问不了本地的图片
项目中有上传图片功能,自定义input type=file 改变透明度和超出部分隐藏,把按钮和 点击的图标放在上传文件的按钮上面,然后又碰到到获取input里面的图片的本地的路径, 在electron ...
- Python实现二叉树的左中右序遍历
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2018/3/18 12:31 # @Author : baoshan # @Site ...
- eclipse jetty 请求的操作无法在使用用户映射区域打开的文件上执行
使用jetty debug代码启动 在eclipse中进行运行调试,碰到无法编辑保存webapp下的文件 提示: 请求的操作无法在使用用户映射区域打开的文件上执行 解决方法: 从 jetty 7 ...
- java多线程20 : ReentrantLock中的方法 ,公平锁和非公平锁
公平锁与非公平锁 ReentrantLock有一个很大的特点,就是可以指定锁是公平锁还是非公平锁,公平锁表示线程获取锁的顺序是按照线程排队的顺序来分配的,而非公平锁就是一种获取锁的抢占机制,是随机获得 ...
- 第22章 RTX 低功耗之停机模式
以下内容转载自安富莱电子: http://forum.armfly.com/forum.php STM32F103 停机模式介绍 本章节我们主要讲解停机模式,停机模式是在 Cortex™-M3 的深睡 ...
- [datatable]排序时指定某列不可排序
datatable是一个jquery扩展的表格插件.其提供了强大的表格功能. 官方地址:http://www.datatables.net/ 在官方示例中,对于表格的是否可排序是在初始化中设置的一个值 ...
- [转]MySQL update join语句
原文地址:https://www.jianshu.com/p/f99665266bb1 在本教程中,您将学习如何使用MySQL UPDATE JOIN语句来执行跨表更新.我们将逐步介绍如何使用INNE ...