public void constrain(int minLeft,int minTop,int maxLeft,int maxTop){
  left=Math.max(minLeft,Math.min(left,maxLeft));
  top=Math.max(minTop,Math.min(top,maxTop));
}

public void constrain ( int minLeft , int minTop , int maxLeft , int maxTop ) { left = Math . max ( minLeft , Math . min ( left , maxLeft ) ) ; top = Math . max ( minTop , Math . min ( top , maxTop ) ) ; }
constrain the widget location to the provided minimum and maximum values .
