Here you can find the source of getElementIndex(Element elem)
Parameter | Description |
---|---|
elem | the element to get the index number for |
public static int getElementIndex(Element elem)
//package com.java2s; /*//from w w w .j av a 2 s . c o 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 index of a given element in the list of its parents elements. * * @param elem the element to get the index number for * @return the index of the given element */ public static int getElementIndex(Element elem) { int i = 0; Element parent = elem.getParentElement(); if (parent != null) { int last = parent.getElementCount() - 1; Element anElem = parent.getElement(i); if (anElem != elem) { while ((i < last) && (anElem != elem)) { anElem = parent.getElement(++i); } } } return i; } }