Example usage for javax.swing JLayeredPane getComponentsInLayer

List of usage examples for javax.swing JLayeredPane getComponentsInLayer

Introduction

In this page you can find the example usage for javax.swing JLayeredPane getComponentsInLayer.

Prototype

public Component[] getComponentsInLayer(int layer) 

Source Link

Document

Returns an array of the components in the specified layer.

Usage

From source file:LayeredPaneDemo4.java

public void setSelected(boolean b) {
    if (b) {/*from www .j  a  va 2s  .c om*/
        if (m_selected != true && getParent() instanceof JLayeredPane) {
            JLayeredPane jlp = (JLayeredPane) getParent();
            int layer = jlp.getLayer(this);
            Component[] components = jlp.getComponentsInLayer(layer);
            for (int i = 0; i < components.length; i++) {
                if (components[i] instanceof InnerFrame) {
                    InnerFrame tempFrame = (InnerFrame) components[i];
                    if (!tempFrame.equals(this))
                        tempFrame.setSelected(false);
                }
            }
            m_selected = true;
            updateBorderColors();
            updateTitleBarColors();
            getGlassPane().setVisible(false);
            repaint();
        }
    } else {
        m_selected = false;
        updateBorderColors();
        updateTitleBarColors();
        getGlassPane().setVisible(true);
        repaint();
    }
}