lineElement = map.getElement(i); start = lineElement.getStartOffset(); offset = scanBackwardLine(buffer.getText( start,lineElement .getEndOffset() - start), openBrackets,closeBrackets, count); count = -1 - offset; if(offset >= 0)
if(--count == 0)
	public void actionPerformed(ActionEvent evt)	{		View view = getView(evt);		Buffer buffer = view.getBuffer();		String openBrackets = (String)buffer			.getProperty("openBrackets");		String closeBrackets = (String)buffer			.getProperty("closeBrackets");		if(closeBrackets.length() != openBrackets.length())		{			view.getToolkit().beep();			return;		}		int count;		int blockStart = 0;		int blockEnd = buffer.getLength();		int selStart = view.getTextArea().getSelectionStart();		int selEnd = view.getTextArea().getSelectionEnd();		Element map = buffer.getDefaultRootElement();		int lineNo = map.getElementIndex(selStart);		Element lineElement = map.getElement(lineNo);		int start = lineElement.getStartOffset();		try		{			int offset = scanBackwardLine(buffer.getText(start,				selStart - start),openBrackets,						      closeBrackets,0);			count = -1 - offset;			if(offset >= 0)			{				blockStart = start + offset;				count = 0;			}			else			{				for(int i = lineNo - 1; i >= 0; i--)				{					lineElement = map.getElement(i);					start = lineElement.getStartOffset();					offset = scanBackwardLine(buffer.getText(						start,lineElement						.getEndOffset() - start),						openBrackets,closeBrackets,						count);					count = -1 - offset;					if(offset >= 0)					{						blockStart = start + offset;						count = 0;						break;					}				}			}			lineNo = map.getElementIndex(selEnd);			lineElement = map.getElement(lineNo);			offset = scanForwardLine(buffer.getText(selEnd,				lineElement.getEndOffset() - selEnd),				openBrackets,closeBrackets,count);			count = -1 - offset;			if(offset >= 0)			{				blockEnd = selEnd + offset;				count = 0;			}			else			{				for(int i = lineNo + 1; i < map.getElementCount();				    i++)				{					lineElement = map.getElement(i);					start = lineElement.getStartOffset();					offset = scanForwardLine(buffer.getText(						start,lineElement.getEndOffset()						- start),openBrackets,								 closeBrackets,								 count);					count = -1 - offset;					if(offset >= 0)					{						blockEnd = start + offset;						count = 0;						break;					}				}			}		}		catch(BadLocationException bl)		{		}		view.getTextArea().select(blockStart,blockEnd);	}