zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    Python 2 中的编码
    奇异值分解及其应用
    c#基础系列3---深入理解ref 和out
    c#基础系列2---深入理解 String
    c#基础系列1---深入理解值类型和引用类型
    广州.NET微软技术俱乐部微信群有用信息集锦(10)
    程序员英语二三事(3)
    BDD实战篇
    BDD实战篇
    广州.NET微软技术俱乐部
  • 原文地址:https://www.cnblogs.com/borter/p/9596304.html
Copyright © 2011-2022 走看看