private void updatePreview(){
  Color newColor=chooser.getColor();
  if (type == FOREGROUND) {
    preview.update(newColor,secondaryColor);
  }
 else {
    preview.update(secondaryColor,newColor);
  }
}

private void updatePreview ( ) { Color newColor = chooser . getColor ( ) ; if ( type == FOREGROUND ) { preview . update ( newColor , secondaryColor ) ; } else { preview . update ( secondaryColor , newColor ) ; } }
update the preview with the new primary color . use as foreground or background depending on the type and use secondary color as the other one .
