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
  • 相关阅读:
    缓存使用的最佳实践
    如何科学的设置线程池
    双检查锁失效
    Minor GC、Major GC和Full GC之间的区别
    full gc频繁的分析及解决案例
    MySQL的并发控制与加锁分析
    全面理解Java内存模型
    JAVA中MAP转LIST
    java 编码转换
    自定义VIew基础
  • 原文地址:https://www.cnblogs.com/borter/p/9596304.html
Copyright © 2011-2022 走看看