protected void removeLayer(Layer[] currentLayers,int index){
  Layer rLayer=currentLayers[index];
  if (!rLayer.isRemovable()) {
    logger.warning("received command to remove " + rLayer.getName() + ", which has been designated as *NOT* removeable");
    return;
  }
  rLayer.setVisible(false);
  Layer[] newLayers=new Layer[currentLayers.length - 1];
  System.arraycopy(currentLayers,0,newLayers,0,index);
  System.arraycopy(currentLayers,index + 1,newLayers,index,currentLayers.length - index - 1);
  BeanContext bc=getBeanContext();
  if (bc != null) {
    bc.remove(rLayer);
  }
  turnLayerOn(false,rLayer);
  rLayer.clearListeners();
  rLayer=null;
  setLayers(newLayers);
}

protected void removeLayer ( Layer [ ] currentLayers , int index ) { Layer rLayer = currentLayers [ index ] ; if ( ! rLayer . isRemovable ( ) ) { logger . warning ( "received command to remove " + rLayer . getName ( ) + ", which has been designated as *NOT* removeable" ) ; return ; } rLayer . setVisible ( false ) ; Layer [ ] newLayers = new Layer [ currentLayers . length - 1 ] ; System . arraycopy ( currentLayers , 0 , newLayers , 0 , index ) ; System . arraycopy ( currentLayers , index + 1 , newLayers , index , currentLayers . length - index - 1 ) ; BeanContext bc = getBeanContext ( ) ; if ( bc != null ) { bc . remove ( rLayer ) ; } turnLayerOn ( false , rLayer ) ; rLayer . clearListeners ( ) ; rLayer = null ; setLayers ( newLayers ) ; }
the version that does the work . the other two functions do sanity checks . calls setlayers ( ) , and removes the layer from the beancontext .
