< prev index next >

src/java.desktop/share/classes/java/awt/Component.java

Print this page

        

*** 9737,9759 **** * * @return the index of this object in its accessible parent */ int getAccessibleIndexInParent() { synchronized (getTreeLock()) { ! int index = -1; ! Container parent = this.getParent(); ! if (parent != null && parent instanceof Accessible) { ! Component ca[] = parent.getComponents(); ! for (int i = 0; i < ca.length; i++) { ! if (ca[i] instanceof Accessible) { ! index++; } ! if (this.equals(ca[i])) { ! return index; } } } return -1; } } /** --- 9737,9767 ---- * * @return the index of this object in its accessible parent */ int getAccessibleIndexInParent() { synchronized (getTreeLock()) { ! if (!(this instanceof Accessible)) { ! return -1; } ! ! AccessibleContext accContext = getAccessibleContext(); ! if (accContext == null) { ! return -1; } + + Accessible parent = accContext.getAccessibleParent(); + if (parent == null) { + return -1; + } + + accContext = parent.getAccessibleContext(); + for (int i = 0; i < accContext.getAccessibleChildrenCount(); i++) { + if (this.equals(accContext.getAccessibleChild(i))) { + return i; } } + return -1; } } /**
< prev index next >