public void calcOffset ( Container compAnchor , Point offset ) { offset . x = 0 ; offset . y = 0 ; Container parent = this ; while ( parent != null ) { offset . x -= parent . getLocation ( ) . x ; offset . y -= parent . getLocation ( ) . y ; parent = parent . getParent ( ) ; if ( parent == compAnchor ) return ; // Success } // Failure - comp not found. offset . x = 0 ; offset . y = 0 ; }
Calculate the offset from the component to this component .