Java JTextComponent Row getRow(int pos, JTextComponent editor)

Here you can find the source of getRow(int pos, JTextComponent editor)

Description

get Row

License

Open Source License

Declaration

public static int getRow(int pos, JTextComponent editor) throws BadLocationException 

Method Source Code

//package com.java2s;
/*//from  w ww  .  j ava2  s.  c om
 * 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 getRow(int pos, JTextComponent editor) throws BadLocationException {
        int rn = (pos == 0) ? 1 : 0;
        int offs = pos;
        while (offs > 0) {
            offs = Utilities.getRowStart(editor, offs) - 1;
            rn++;
        }
        return rn;
    }
}

Related

  1. getRow(JTextComponent editor, int pos)
  2. getRowStart(JTextComponent c, int offs)