예제 #1
0
    public void insertUpdate(DocumentEvent evt) {
      documentChanged(evt);

      int offset = evt.getOffset();
      int length = evt.getLength();

      int newStart;
      int newEnd;

      if (selectionStart > offset || (selectionStart == selectionEnd && selectionStart == offset))
        newStart = selectionStart + length;
      else newStart = selectionStart;

      if (selectionEnd >= offset) newEnd = selectionEnd + length;
      else newEnd = selectionEnd;

      select(newStart, newEnd);
    }
예제 #2
0
    public void removeUpdate(DocumentEvent evt) {
      documentChanged(evt);

      int offset = evt.getOffset();
      int length = evt.getLength();

      int newStart;
      int newEnd;

      if (selectionStart > offset) {
        if (selectionStart > offset + length) newStart = selectionStart - length;
        else newStart = offset;
      } else newStart = selectionStart;

      if (selectionEnd > offset) {
        if (selectionEnd > offset + length) newEnd = selectionEnd - length;
        else newEnd = offset;
      } else newEnd = selectionEnd;

      select(newStart, newEnd);
    }