buffer.remove(lineElement.getStartOffset(), lineElement.getEndOffset() - lineElement.getStartOffset());
int start = lineElement.getStartOffset(); int end = lineElement.getEndOffset(); int length = buffer.getLength(); if(end > length) { end--; start--; } buffer.remove(start,end - start);
	public void actionPerformed(ActionEvent evt)	{		View view = getView(evt);		Buffer buffer = view.getBuffer();		Element map = buffer.getDefaultRootElement();		Element lineElement = map.getElement(map.getElementIndex(			view.getTextArea().getCaretPosition()));		try		{			buffer.remove(lineElement.getStartOffset(),				lineElement.getEndOffset()				- lineElement.getStartOffset());		}		catch(BadLocationException bl)		{			/* now, if anybody from Sun is reading this, let			 * me make myself clear: BadLocationException SUX.			 * why not throw a StringIndexOutOfBounds, or at			 * least make BadLocationException a RuntimeException?			 */		}	}