当前位置: 首页>>代码示例>>Java>>正文


Java TreeModelEvent.getChildren方法代码示例

本文整理汇总了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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:EventBroadcaster.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:EventBroadcaster.java

示例3: treeNodesInserted

import javax.swing.event.TreeModelEvent; //导入方法依赖的package包/类
@Override
public void treeNodesInserted(TreeModelEvent e)
{
	if( e.getChildren().length >= 1 )
	{
		expandToNode((SchemaNode) e.getChildren()[0]);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:9,代码来源:SchemaTree.java

示例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();
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:49,代码来源:FixedHeightLayoutCache.java


注:本文中的javax.swing.event.TreeModelEvent.getChildren方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。