question: 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 ) ; }
target:  The version that does the work. The other two functions do sanity checks. Calls setLayers(), and removes the layer from the BeanContext.