Example usage for javax.swing JLayeredPane getLayer

List of usage examples for javax.swing JLayeredPane getLayer

Introduction

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

Prototype

public int getLayer(Component c) 

Source Link

Document

Returns the layer attribute for the specified Component.

Usage

From source file:LayeredPaneDemo4.java

public void setSelected(boolean b) {
    if (b) {/*from  ww w  .  j  a  v a 2  s  . co  m*/
        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();
    }
}