if (componentWithSelection != null) if (componentWithSelection != textComponent) { Caret c = componentWithSelection.getCaret(); c.setDot(c.getDot()); } componentWithSelection = textComponent;
  private void handleHighlight()  {    Highlighter highlighter = textComponent.getHighlighter();        if (highlighter == null)      return;        int p0 = Math.min(dot, mark);    int p1 = Math.max(dot, mark);        if (selectionVisible)      {	try	  {	    if (highlightEntry == null)	      highlightEntry = highlighter.addHighlight(p0, p1, getSelectionPainter());	    else	      highlighter.changeHighlight(highlightEntry, p0, p1);	  }	catch (BadLocationException e)	  {	    // This should never happen.	    throw new InternalError();	  }      }    else      {	if (highlightEntry != null)	  {	    highlighter.removeHighlight(highlightEntry);	    highlightEntry = null;	  }      }  }