end = Math.max(end, 0);
end = Math.max(end, start);
  public void select(int start, int end)  {    int length = doc.getLength();        start = Math.max(start, 0);    start = Math.min(start, length);    end = Math.max(end, 0);    end = Math.min(end, length);    setCaretPosition(start);    moveCaretPosition(end);  }