indent = MiscUtilities.getLeadingWhiteSpace( buffer.getText(start,lineElement .getEndOffset() - start)); buffer.insertString(start + indent,boxComment,null);
buffer.insertString(start,boxComment,null);
	public void actionPerformed(ActionEvent evt)	{		View view = getView(evt);		JEditTextArea textArea = view.getTextArea();		Buffer buffer = view.getBuffer();		String commentStart = (String)buffer.getProperty("commentStart");		String commentEnd = (String)buffer.getProperty("commentEnd");		String boxComment = (String)buffer.getProperty("boxComment");		if(commentStart == null || commentEnd == null			|| boxComment == null)		{			view.getToolkit().beep();			return;		}		commentStart = commentStart + ' ';		commentEnd = ' ' + commentEnd;		boxComment = boxComment + ' ';		int selectionStart = textArea.getSelectionStart();		int selectionEnd = textArea.getSelectionEnd();		int startLine = textArea.getSelectionStartLine();		int endLine = textArea.getSelectionEndLine();		Element map = buffer.getDefaultRootElement();		buffer.beginCompoundEdit();		try		{			Element lineElement = map.getElement(startLine);			int start = lineElement.getStartOffset();			int indent = MiscUtilities.getLeadingWhiteSpace(				buffer.getText(start,lineElement.getEndOffset()				- start));			buffer.insertString(Math.max(start + indent,selectionStart),				commentStart,null);			for(int i = startLine + 1; i <= endLine; i++)			{				lineElement = map.getElement(i);				start = lineElement.getStartOffset();				indent = MiscUtilities.getLeadingWhiteSpace(					buffer.getText(start,lineElement					.getEndOffset() - start));				buffer.insertString(start + indent,boxComment,null);			}			lineElement = map.getElement(endLine);			start = lineElement.getStartOffset();			indent = MiscUtilities.getLeadingWhiteSpace(buffer				.getText(start,lineElement.getEndOffset()				- start));			buffer.insertString(Math.max(start + indent,textArea				.getSelectionEnd()),commentEnd,null);		}		catch(BadLocationException bl)		{			Log.log(Log.ERROR,this,bl);		}		finally		{			buffer.endCompoundEdit();		}		textArea.select(textArea.getCaretPosition(),			textArea.getCaretPosition());	}