Java Swing Text Format getRowIndex(Element cell)

Here you can find the source of getRowIndex(Element cell)

Description

get the row index for a given table cell

License

Open Source License

Parameter

Parameter Description
cell the cell element to get the row index for

Return

the row index of the given cell element

Declaration

public static int getRowIndex(Element cell) 

Method Source Code

//package com.java2s;
/*//ww w  . ja v  a 2  s .  co  m
 * This file is part of the Scriba source distribution. This is free, open-source 
 * software. For full licensing information, please see the LicensingInformation file
 * at the root level of the distribution.
 *
 * Copyright (c) 2006-2007 Kobrix Software, Inc.
 */

import javax.swing.text.Element;

public class Main {
    /**
     * get the row index for a given table cell
     * 
     * @param cell the cell element to get the row index for
     * 
     * @return the row index of the given cell element
     */
    public static int getRowIndex(Element cell) {
        Element thisRow = cell.getParentElement();
        Element table = thisRow.getParentElement();
        int index = 0;
        int count = table.getElementCount();
        Element elem = table.getElement(index);
        while (!elem.equals(thisRow) && index < count) {
            elem = table.getElement(++index);
        }
        return index;
    }
}

Related

  1. formatNumericString(String string, String mask)
  2. getBidiVisualPosition(final int start, final int end, final Element neighbouringElement, final int pos, final Position.Bias b0, final Position.Bias[] biasRet, final int length, final boolean toWest, final boolean isLTR)
  3. getElementByPosition(final Element rootElement, final int pos)
  4. getElementIndex(Element elem)
  5. getRegexFormatter(String regex)
  6. getTrivialVisualPosition(final boolean toWest, final int pos, final Position.Bias bias, final int docLength, final Position.Bias[] biasRet, final boolean isLTR)