Java Swing HTML getRowIndex(final Element cell)

Here you can find the source of getRowIndex(final 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(final Element cell) 

Method Source Code

//package com.java2s;
/*/*  www  .j av a 2s .c o  m*/
 * SimplyHTML, a word processor based on Java, HTML and CSS
 * Copyright (C) 2002 Ulrich Hilger
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

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(final Element cell) {
        final Element thisRow = cell.getParentElement();
        final Element table = thisRow.getParentElement();
        int index = 0;
        final int count = table.getElementCount();
        Element elem = table.getElement(index);
        while (!elem.equals(thisRow) && index < count) {
            elem = table.getElement(++index);
        }
        return index;
    }
}

Related

  1. findElementUp(final String name1, final String name2, final Element start)
  2. findLinkElementUp(Element elem)
  3. findLinkUp(Element elem)
  4. getHTMLFromXML(String xml, URL xsl)
  5. getImgs(final String html)
  6. hasClass(AttributeSet attr, String className)
  7. htmlToPlain(String html)
  8. isUnderline(Element element)
  9. loadStyleSheet(URL url)