Code example for JTextComponent

Methods: getCaretPositiongetDocument

0
     * @param offset Offset position 
     * @return Column number starting in 0. 
     */ 
    public static int getColumn(JTextComponent txtCmp, int offset)
    { 
        return txtCmp.getCaretPosition() - getOffsetStartLine(txtCmp, offset);
    } 
 
    /** 
     * Given an offset, returns the offset where the line begins. 
     *  
     * @param offset Offset position. 
     * @return Offset where the line begins. 
     */ 
    public static int getOffsetStartLine(JTextComponent txtCmp, int offset)
    { 
        return getOffsetStartLine(txtCmp.getDocument(), offset);
    } 
 
    /** 
     * Given an offset, returns the offset where the line begins. 
     *