Code example for Position

Methods: getOffset

    public StyledDocument getDocument() {
        return document;
    public int getOffset() { 
        return position.getOffset();
    public DocumentLine getContainingLine() { 
        try { 
            return new DocumentLine(getDocument(), NbDocument.findLineNumber(getDocument(), getOffset())); 
        } catch (BadLocationException ex) {
            throw new IllegalStateException("Not reachable if the position was originally from this document.", ex);
    public DocumentPoint add(int offset) throws BadLocationException {
        return new DocumentPoint(getDocument(), this.getOffset() + offset);
Experience pair programming with AI  Get Codota for Java