當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。