本文整理汇总了Java中javax.swing.event.TreeModelEvent.getChildren方法的典型用法代码示例。如果您正苦于以下问题:Java TreeModelEvent.getChildren方法的具体用法?Java TreeModelEvent.getChildren怎么用?Java TreeModelEvent.getChildren使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.event.TreeModelEvent
的用法示例。
在下文中一共展示了TreeModelEvent.getChildren方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeRowIndices
import javax.swing.event.TreeModelEvent; //导入方法依赖的package包/类
/**
* Compute real table row indices of nodes that are affected by the event.
*
* @param e Event description.
* @return Indices of rows in the table where the nodes (affected by the
* event) are displayed, or null if they are not available.
*/
private int[] computeRowIndices(TreeModelEvent e) {
int[] rowIndices;
int parentRow = getLayout().getRowForPath(e.getTreePath());
if (e.getChildren() != null) {
rowIndices = new int[e.getChildren().length];
for (int i = 0; i < e.getChildren().length; i++) {
TreePath childPath =
e.getTreePath().pathByAddingChild(e.getChildren()[i]);
int index = getLayout().getRowForPath(childPath);
rowIndices[i] = index < 0
// child node is not shown yet, compute child row from
// parent row and index of the child
? parentRow + e.getChildIndices()[i] + 1
: index;
}
} else {
rowIndices = null;
}
return rowIndices;
}
示例2: translateEvent
import javax.swing.event.TreeModelEvent; //导入方法依赖的package包/类
/** Creates an identical TreeModelEvent with the model we are proxying
* as the event source */
private TreeModelEvent translateEvent (TreeModelEvent e) {
//Create a new TreeModelEvent with us as the source
TreeModelEvent nue = new TreeModelEvent (getModel(), e.getPath(),
e.getChildIndices(), e.getChildren());
return nue;
}
示例3: treeNodesInserted
import javax.swing.event.TreeModelEvent; //导入方法依赖的package包/类
@Override
public void treeNodesInserted(TreeModelEvent e)
{
if( e.getChildren().length >= 1 )
{
expandToNode((SchemaNode) e.getChildren()[0]);
}
}
示例4: treeNodesRemoved
import javax.swing.event.TreeModelEvent; //导入方法依赖的package包/类
/**
* <p>Invoked after nodes have been removed from the tree. Note that
* if a subtree is removed from the tree, this method may only be
* invoked once for the root of the removed subtree, not once for
* each individual set of siblings removed.</p>
*
* <p>e.path() returns the former parent of the deleted nodes.</p>
*
* <p>e.childIndices() returns the indices the nodes had before they were deleted in ascending order.</p>
*/
public void treeNodesRemoved(TreeModelEvent e) {
if(e != null) {
int changedIndexs[];
int maxCounter;
TreePath parentPath = SwingUtilities2.getTreePath(e, getModel());
FHTreeStateNode changedParentNode = getNodeForPath
(parentPath, false, false);
changedIndexs = e.getChildIndices();
// PENDING(scott): make sure that changedIndexs are sorted in
// ascending order.
if(changedParentNode != null && changedIndexs != null &&
(maxCounter = changedIndexs.length) > 0) {
Object[] children = e.getChildren();
boolean isVisible =
(changedParentNode.isVisible() &&
changedParentNode.isExpanded());
for(int counter = maxCounter - 1; counter >= 0; counter--) {
changedParentNode.removeChildAtModelIndex
(changedIndexs[counter], isVisible);
}
if(isVisible) {
if(treeSelectionModel != null)
treeSelectionModel.resetRowSelection();
if (treeModel.getChildCount(changedParentNode.
getUserObject()) == 0 &&
changedParentNode.isLeaf()) {
// Node has become a leaf, collapse it.
changedParentNode.collapse(false);
}
visibleNodesChanged();
}
else if(changedParentNode.isVisible())
visibleNodesChanged();
}
}
}