Here you can find the source of getColumn(int pos, JTextComponent editor)
public static int getColumn(int pos, JTextComponent editor) throws BadLocationException
//package com.java2s; /*//from w ww.j a v a2 s .c o m * Copyright (c) 2011 - 2012. Elega9t Ltd. All rights reserved. * ELEGA9T PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.Copyright (c) 2011 - 2012. Elega9t Ltd. All rights reserved. */ import javax.swing.text.BadLocationException; import javax.swing.text.JTextComponent; import javax.swing.text.Utilities; public class Main { public static int getColumn(int pos, JTextComponent editor) throws BadLocationException { return pos - Utilities.getRowStart(editor, pos) + 1; } }