zoukankan      html  css  js  c++  java
  • e832. 从JTabbedPane中移动卡片

    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
  • 相关阅读:
    浏览器返回按钮不会触发onLoad事件
    TCP慢启动算法
    TCP协议三次握手过程分析
    关于新增和编辑
    Mock, 让你的开发脱离接口
    到底数据驱动是个什么玩意
    pagination分页插件
    关于状态切换
    在线占位图网站
    Arduino nano 与 w5500模块的连接与调试
  • 原文地址:https://www.cnblogs.com/borter/p/9596312.html
Copyright © 2011-2022 走看看