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. 每日英语:The best time for coffee is 10:30 a.m.

    For many of us, it is the rocket fuel that gets us going first thing in the morning. But one expert ...

  2. 【Android】json格式详解

    JSON有两种结构 1. “名称/值”对的集合(A collection of name/value pairs).    不同的语言中,它被理解为对象(object),记录(record),结构(s ...

  3. iframe自适应当前页面高度

    <style type="text/css"> *{margin:0;padding:0;list-style-type:none;} </style> & ...

  4. elementui常用知识点总结

    1.淡入淡出效果: <transition name="el-fade-in-linear"> <div v-show="show" clas ...

  5. Ubuntu 安装 mysql

    sudo apt-get install mysql-server sudo apt install mysql-client sudo apt install libmysqlclient-dev

  6. 别人不会给你说的---C语言中数组名和指针的区别 及 sizeof用法

    引自: http://blog.csdn.net/tianyue168/article/details/5781924 #i nclude <iostream.h> int  main( ...

  7. CentOS 7 下安装 Nginx(转)

    转载自:http://www.linuxidc.com/Linux/2016-09/134907.htm 安装所需环境 Nginx 是 C语言 开发,建议在 Linux 上运行,当然,也可以安装 Wi ...

  8. Gnome3 安装系统监视器

    . . . . . 之前使用Gnome2的时候可以向面板上添加一个系统监视器,相信很多人都用过这个实用的小工具,可以很方便的了解系统的运行概况.但是自从使用了Gnome3之后这个小工具不见了,Gnom ...

  9. shell文本处理

    1.文件整理employee文件中记录了工号和姓名employee.txt:100 Jason Smith 200 John Doe 300 Sanjay Gupta 400 Ashok Sharma ...

  10. Android——selector背景选择器的使用详解(二)

    在开发应用中,很多情况下要设计listview或button控件的背景,下面总结一下android的selector的用法:1.在drawable中配置Android的selector.将如下的XML ...