public void replace(Component existingComponent,Component newComponent){
  if (existingComponent == null || newComponent == null) {
    throw new IllegalArgumentException("Components must be non-null");
  }
  if (springsChanged) {
    registerComponents(horizontalGroup,HORIZONTAL);
    registerComponents(verticalGroup,VERTICAL);
  }
  ComponentInfo info=componentInfos.remove(existingComponent);
  if (info == null) {
    throw new IllegalArgumentException("Component must already exist");
  }
  host.remove(existingComponent);
  if (newComponent.getParent() != host) {
    host.add(newComponent);
  }
  info.setComponent(newComponent);
  componentInfos.put(newComponent,info);
  invalidateHost();
}

public void replace ( Component existingComponent , Component newComponent ) { if ( existingComponent == null || newComponent == null ) { throw new IllegalArgumentException ( "Components must be non-null" ) ; } if ( springsChanged ) { registerComponents ( horizontalGroup , HORIZONTAL ) ; registerComponents ( verticalGroup , VERTICAL ) ; } ComponentInfo info = componentInfos . remove ( existingComponent ) ; if ( info == null ) { throw new IllegalArgumentException ( "Component must already exist" ) ; } host . remove ( existingComponent ) ; if ( newComponent . getParent ( ) != host ) { host . add ( newComponent ) ; } info . setComponent ( newComponent ) ; componentInfos . put ( newComponent , info ) ; invalidateHost ( ) ; }
replaces an existing component with a new one .
