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

最新文章

  1. WebForm 页面传值
  2. XE6移动开发环境搭建之IOS篇(6):设置Mac OSX的网络。(有图有真相)
  3. 如何延长windows评估版的方法
  4. magento 切换数据库,使用不同数据库
  5. 使用Ant打包工具 基本介绍
  6. Extjs文本输入框
  7. JDK Environment Variable And Change default JDK
  8. [topcoder] EllysNumberGuessing
  9. vijos1067守望者的逃离
  10. 18 4Sum(寻找四个数之和为指定数的集合Medium)
  11. span里设置高度
  12. 关于cvScalar的那些事
  13. SQL Server 文件路径
  14. Dede CMS如何在文章中增加“附件下载”操作说明
  15. 前端应该知道的Web Components
  16. CF | Alyona and Numbers
  17. pyenv安装及常用命令
  18. php中把美国时间转为北京时间的自定义
  19. PHP中如何给日期加上一个月/天
  20. sql练习题及经典题

热门文章

  1. Fabric V1 交易的生命周期
  2. ex:Could not load file or assembly 'System.Web.Helpers, Version=2.0.0.0, Culture=neutral, . 系统找不到指定的文件。
  3. javascript基础拾遗(九)
  4. 每日英语:When The Boss Works Long Hours, Do We All Have To?
  5. bash shell(4):读取文件大小,移动文件,复制文件,字符串转数字
  6. NGUI制作字体的三种方法
  7. 【Android】Gesture Detector
  8. Asp.Net计算程序执行速度
  9. Spark 保存文件 自定义分隔符
  10. 将String转换成InputStream