Java tutorial
//package com.java2s; /* * 08/06/2004 * * RSyntaxUtilities.java - Utility methods used by RSyntaxTextArea and its * views. * * This library is distributed under a modified BSD license. See the included * RSyntaxTextArea.License.txt file for details. */ import javax.swing.text.Document; import javax.swing.text.Element; public class Main { private static final Element getLineElem(Document d, int offs) { Element map = d.getDefaultRootElement(); int index = map.getElementIndex(offs); Element elem = map.getElement(index); if ((offs >= elem.getStartOffset()) && (offs < elem.getEndOffset())) { return elem; } return null; } }