Component myComp = c; while(! componentToLayer.containsKey(myComp))
Integer layerObj; if (c instanceof JComponent)
  public int getLayer(Component c)  {    Component myComp = c;    while(! componentToLayer.containsKey(myComp))      {	myComp = myComp.getParent();	if (myComp == null)	  break;      }    if (myComp == null)      throw new IllegalArgumentException	("component is not in this JLayeredPane");    Integer layerObj = (Integer) componentToLayer.get(myComp);    return layerObj.intValue();  }