Example usage for javax.swing JComponent getComponentCount

List of usage examples for javax.swing JComponent getComponentCount

Introduction

In this page you can find the example usage for javax.swing JComponent getComponentCount.

Prototype

public int getComponentCount() 

Source Link

Document

Gets the number of components in this panel.

Usage

From source file:org.openmicroscopy.shoola.agents.util.ui.ScriptComponent.java

/** 
 * Iterates through the components and sets the background color.
 * /*  w w  w  .j av a  2s  . c  o m*/
 * @param c The component to handle
 * @param background The color to set.
 */
private void setComponentColor(JComponent c, Color background) {
    c.setBackground(background);
    if (c.getComponentCount() > 0) {
        Component[] components = c.getComponents();
        for (int i = 0; i < components.length; i++) {
            if (components[i] instanceof JComponent) {
                setComponentColor((JComponent) components[i], background);
            }
        }
    }
}

From source file:org.xulux.swing.util.NativeWidgetHandler.java

/**
 * @see org.xulux.nyx.gui.INativeWidgetHandler#setLocationOnWidget(org.xulux.nyx.gui.Widget, int, int)
 *///  w w w  .jav a2s  . co m
public void setLocationOnWidget(Widget parent, int x, int y) {
    if (parent != null && parent.getNativeWidget() != null) {
        JComponent comp = (JComponent) parent.getNativeWidget();
        // set the location on the last component added..
        if (comp.getComponentCount() > 0) {
            Component childComp = comp.getComponent(comp.getComponentCount() - 1);
            setLocationOnWidget(childComp, x, y);
        }
    }
}