|
qflib 0.99 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.qfs.lib.tree.IndexBasedTreeAdapter
de.qfs.lib.gui.AWTTreeAdapter
This is a TreeAdapter for the AWT Component hierarchy. It assumes that all nodes passed are Components.
Special care is taken to handle JMenus. These have a logical hierarchy, meaning that JMenuItems are permanent children of a JMenu and a physical hierarchy in which the Items are added to the menu only while it is popped up.
By default the logical menu structure is assumed. If you want to traverse
the component tree's physical structure, use the AWTTreeAdapter(boolean)
constructor with a false
argument.
Warning: The logical structure is inconsistent in that the parent menu of a MenuItem cannot be determined if the menu is not posted. This doesn't prevent traversing the hierarchy though.
Nested Class Summary |
Nested classes inherited from class de.qfs.lib.tree.IndexBasedTreeAdapter |
IndexBasedTreeAdapter.ChildEnumeration |
Constructor Summary | |
AWTTreeAdapter()
Create a new AWTTreeAdapter. |
|
AWTTreeAdapter(boolean specialJMenu)
Create a new AWTTreeAdapter. |
Method Summary | |
int |
getChildCount(java.lang.Object parent)
Get the number of children of a node. |
java.lang.Object |
getChildNode(java.lang.Object parent,
int index)
Get a child of a node. |
int |
getIndexOfChildNode(java.lang.Object parent,
java.lang.Object child)
Get the index of a child in a node's list of children. |
java.lang.Object |
getParentNode(java.lang.Object child)
Get the parent of a node. |
boolean |
isLeaf(java.lang.Object node)
Query whether a node is a leaf. |
Methods inherited from class de.qfs.lib.tree.IndexBasedTreeAdapter |
getChildren, getFirstChildNode, getLastChildNode, getNextSibling, getPreviousSibling, isEnumerationBased, isIndexBased, isLinkBased |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public AWTTreeAdapter()
public AWTTreeAdapter(boolean specialJMenu)
specialJMenu
- Whether to treat JMenus specially (see class
documentation). Default is true.Method Detail |
public java.lang.Object getParentNode(java.lang.Object child)
child
- The node to query for the parent.
public boolean isLeaf(java.lang.Object node)
node
- The node to query.
public int getChildCount(java.lang.Object parent)
parent
- The node to query.
public java.lang.Object getChildNode(java.lang.Object parent, int index) throws java.lang.IndexOutOfBoundsException
parent
- The node to query.index
- The index of the child.
java.lang.IndexOutOfBoundsException
- If the index is invalid.public int getIndexOfChildNode(java.lang.Object parent, java.lang.Object child)
parent
- The node to query.child
- The child to look for.
|
qflib 0.99 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |