code: public synchronized ProgressBar setMax(int max) {
          if(max < min) {
              setMin(max);
          }
          if(max < value) {
              setValue(max);
          }
          if(this.max != max) {
              this.max = max;
              invalidate();
          }
          return this;
      }
docs: Updates the <i>maximum</i> value of this progress bar. If the current <i>minimum</i> and/or <i>value</i> are
  greater than this new <i>maximum</i>, they are automatically adjusted so that the range is still valid.
  @param max New <i>maximum</i> value to assign to this progress bar
  @return Itself