if(selectedText != null)
if(selectedText != null && selectedText.length() != 0)
	public void setSelectedText(Selection s, String selectedText)	{		if(!isEditable())		{			throw new InternalError("Text component"				+ " read only");		}		buffer.beginCompoundEdit();		try		{			if(s instanceof Selection.Rect)			{				Element map = buffer.getDefaultRootElement();				int start = s.start - map.getElement(s.startLine)					.getStartOffset();				int end = s.end - map.getElement(s.endLine)					.getStartOffset();				// Certain rectangles satisfy this condition...				if(end < start)				{					int tmp = end;					end = start;					start = tmp;				}				int lastNewline = 0;				int currNewline = 0;				for(int i = s.startLine; i <= s.endLine; i++)				{					Element lineElement = map.getElement(i);					int lineStart = lineElement.getStartOffset();					int lineEnd = lineElement.getEndOffset() - 1;					int rectStart = Math.min(lineEnd,lineStart + start);					buffer.remove(rectStart,Math.min(lineEnd - rectStart,						end - start));					if(selectedText == null)						continue;					currNewline = selectedText.indexOf('\n',lastNewline);					if(currNewline == -1)						currNewline = selectedText.length();					buffer.insertString(rectStart,selectedText						.substring(lastNewline,currNewline),null);					lastNewline = Math.min(selectedText.length(),						currNewline + 1);				}				if(selectedText != null &&					currNewline != selectedText.length())				{					int offset = map.getElement(s.endLine)						.getEndOffset() - 1;					buffer.insertString(offset,"\n",null);					buffer.insertString(offset + 1,selectedText						.substring(currNewline + 1),null);				}			}			else			{				buffer.remove(s.start,s.end - s.start);				if(selectedText != null)				{					buffer.insertString(s.start,						selectedText,null);				}			}		}		catch(BadLocationException bl)		{			Log.log(Log.ERROR,this,bl);		}		// No matter what happends... stops us from leaving buffer		// in a bad state		finally		{			buffer.endCompoundEdit();		}		selectNone();	}