Package com.illumon.iris.gui.util
Class TextEditorUtil
java.lang.Object
com.illumon.iris.gui.util.TextEditorUtil
public class TextEditorUtil extends Object
A utility class with methods for helping text editors.
-
Constructor Summary
Constructors Constructor Description TextEditorUtil()
-
Method Summary
Modifier and Type Method Description static Element
getElementByLineNumber(JTextComponent comp, int line)
Gets the element for a line number.static int
getLineNumber(JTextComponent comp, int offset)
Gets the line number for an offset.static int
getSelectionEnd(Caret caret)
Gets the end offset of a selection.static int
getSelectionStart(Caret caret)
Gets the start offset of a selection.
-
Constructor Details
-
TextEditorUtil
public TextEditorUtil()
-
-
Method Details
-
getSelectionStart
Gets the start offset of a selection.- Parameters:
caret
- the text component caret- Returns:
- the start offset of a selection
-
getSelectionEnd
Gets the end offset of a selection.- Parameters:
caret
- the text component caret- Returns:
- the end offset of a selection
-
getLineNumber
Gets the line number for an offset.- Parameters:
comp
- the text componentoffset
- the offset- Returns:
- the line number
- Throws:
BadLocationException
- if the offset is outside the document range
-
getElementByLineNumber
public static Element getElementByLineNumber(JTextComponent comp, int line) throws BadLocationExceptionGets the element for a line number.- Parameters:
comp
- the text componentline
- the line number- Returns:
- the element for the line number
- Throws:
BadLocationException
- if the line number is outside the document range
-