To move a tab, it must first be removed and then reinserted into the tabbed pane as a new tab. Unfortunately, since there is no object that represents a tab, it is necessary to record all of the tab's properties before moving it and to restore them after the new tab has been created.

This example moves the last tab to the first position:

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

    int src = pane.getTabCount()-1;
int dst = 0; // Get all the properties
Component comp = pane.getComponentAt(src);
String label = pane.getTitleAt(src);
Icon icon = pane.getIconAt(src);
Icon iconDis = pane.getDisabledIconAt(src);
String tooltip = pane.getToolTipTextAt(src);
boolean enabled = pane.isEnabledAt(src);
int keycode = pane.getMnemonicAt(src);
int mnemonicLoc = pane.getDisplayedMnemonicIndexAt(src);
Color fg = pane.getForegroundAt(src);
Color bg = pane.getBackgroundAt(src); // Remove the tab
pane.remove(src); // Add a new tab
pane.insertTab(label, icon, comp, tooltip, dst); // Restore all properties
pane.setDisabledIconAt(dst, iconDis);
pane.setEnabledAt(dst, enabled);
pane.setMnemonicAt(dst, keycode);
pane.setDisplayedMnemonicIndexAt(dst, mnemonicLoc);
pane.setForegroundAt(dst, fg);
pane.setBackgroundAt(dst, bg);
Related Examples

e832. 从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. e833. 获得JTabbedPane中的卡片

    This example retrieves all the tabs in a tabbed pane: // To create a tabbed pane, see e828 创建JTabbed ...

  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. Oracle根据表生成系统流水号

    1.建表tablewater create table TABLEWATER ( tb_id INTEGER not null, vc_table_name ), num_water_no ) )vc ...

  2. angular.js测试框架protracotr安装所需的node版本

    protractor内代码的语法是基于ES6的,比如:里面用到了展开运算符“...”,node.js 6.0以下是不支持该语法特性. 所以,安装protractor是不会报错,但运行webdriver ...

  3. MVC的项目部署成应用程序或虚拟目录路径的问题

    1.js和css的引用出错 a.~/可以取得应用程序目录 b. ./定位到路径,./代表到本目录,../代表父级目录 2.打开页面view a. ./定位到路径 3.img src   a. ./定位 ...

  4. ZooKeeper学习之文件系统的布局和格式

    本文来谈谈快照文件,事务日志文件在文件系统中是如何存放的. 写事务日志是事务处理的关键步骤,所以高度建议在一个独立的磁盘上存储.快照不需要在独立的磁盘存储,因为它们是由一个后台线程以懒汉式的(lazi ...

  5. 【Java】IO Stream详细解读

    成鹏致远 | 2013年12月31日 什么是IO Java中I/O操作主要是指使用Java进行输入,输出操作. Java所有的I/O机制都是基于数据流进行输入输出,这些数据流表示了字符或者字节数据的流 ...

  6. 【Socket】linux网络扫描程序开发

      1.mystery引入    1)系统入侵步骤:系统发现->漏洞探测->漏洞利用->痕迹清除    2)扫描器分类:主机与网络扫描器:端口服务扫描器:服务漏洞扫描器    3)T ...

  7. MediaType是application/x-www-form-urlencoded的接口测试方法

    先看接口: @POST @Path("/deleteById") //@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaTy ...

  8. Python3高级用法综合举例

    [本文出自天外归云的博客园] 举例 下面代码围绕一个Student类综合举例说明装饰器.生成器.动态获取/添加类成员.列表推导式.reduce函数.lambda表达式的实际应用: from funct ...

  9. egret list不显示问题

    1.循环滚动 2.单格滚动 不太清楚是把哪个约束勾上了,结果一直不显示,折腾了许久. 另外也不要把下面的这个约束勾上,否则不能滑动.

  10. 适配器模式,装饰模式,代理模式异同<转>

    节前把3个设计模式的学习心得分享了一下,分别是适配器模式,装饰模式,代理模式. 但是似乎越写越有些迷糊,这三种模式都有着一些大同小异的地方,总是有些搞不清. 今天再重新学习下,把学习心得分享给大家一下 ...