code: private void applyMax(Dimension dim) {
  	if (getMaxHeight() > 0) {
  	  dim.height = Math.min(dim.height, getMaxHeight());
  	}
  	if (getMaxWidth() > 0) {
  	  dim.width = Math.min(dim.width, getMaxWidth());
  	}
    }
docs: Applies the maximum height and width to the dimension.
  
  @param dim
  the dimension to be limited