Example usage for javax.swing JTabbedPane getComponents

List of usage examples for javax.swing JTabbedPane getComponents

Introduction

In this page you can find the example usage for javax.swing JTabbedPane getComponents.

Prototype

public Component[] getComponents() 

Source Link

Document

Gets all the components in this container.

Usage

From source file:com.haulmont.cuba.desktop.gui.components.DesktopComponentsHelper.java

/**
 * Determines whether component will be displayed on the screen.
 *
 * @param component component//from  ww w . j av a 2 s.  c  o  m
 * @return true if the component and all of its ancestors are visible
 */
public static boolean isRecursivelyEnabled(java.awt.Component component) {
    if (component.getParent() instanceof JTabbedPane) {
        JTabbedPane jTabbedPane = (JTabbedPane) component.getParent();

        boolean tabVisible = false;
        for (java.awt.Component childComponent : jTabbedPane.getComponents()) {
            if (childComponent == component) {
                tabVisible = true;
                break;
            }
        }

        return tabVisible && isRecursivelyEnabled(component.getParent());
    }

    return component.isEnabled()
            && (component.getParent() == null || isRecursivelyEnabled(component.getParent()))
            && isRecursivelyVisible(component);
}

From source file:com.haulmont.cuba.desktop.gui.components.DesktopComponentsHelper.java

/**
 * Determines whether component will be displayed on the screen.
 *
 * @param component component/*from w  w  w. j a  va2s  .c  o m*/
 * @return true if the component and all of its ancestors are visible
 */
public static boolean isRecursivelyVisible(java.awt.Component component) {
    if (component.getParent() instanceof JTabbedPane) {
        JTabbedPane jTabbedPane = (JTabbedPane) component.getParent();

        boolean tabVisible = false;
        for (java.awt.Component childComponent : jTabbedPane.getComponents()) {
            if (childComponent == component) {
                tabVisible = true;
                break;
            }
        }

        return tabVisible && isRecursivelyVisible(component.getParent());
    }

    if (component.getParent() instanceof CollapsiblePanel) {
        return isRecursivelyVisible(component.getParent());
    }

    return component.isVisible()
            && (component.getParent() == null || isRecursivelyVisible(component.getParent()));
}

From source file:org.bibsonomy.plugin.jabref.listener.TabbedPaneChangeListener.java

public void stateChanged(ChangeEvent e) {
    if (e.getSource() instanceof JTabbedPane) {
        JTabbedPane pane = (JTabbedPane) e.getSource();
        Component[] components = pane.getComponents();
        for (Component c : components) {
            BasePanel bp = (BasePanel) c;
            if (bp.database() != null) {
                bp.database().addDatabaseChangeListener(databaseChangeListener);
            } else {
                log.warn("found tab-component without database");
            }/*from  w  w w.  j a v  a2  s. c om*/
        }
        if (components.length == 0) {
            log.info("pane has no tab-components");
        }
    }
}