當前位置: 首頁>>代碼示例>>Java>>正文


Java DefaultTreeModel.nodesWereInserted方法代碼示例

本文整理匯總了Java中javax.swing.tree.DefaultTreeModel.nodesWereInserted方法的典型用法代碼示例。如果您正苦於以下問題:Java DefaultTreeModel.nodesWereInserted方法的具體用法?Java DefaultTreeModel.nodesWereInserted怎麽用?Java DefaultTreeModel.nodesWereInserted使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.tree.DefaultTreeModel的用法示例。


在下文中一共展示了DefaultTreeModel.nodesWereInserted方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: generateTreePath

import javax.swing.tree.DefaultTreeModel; //導入方法依賴的package包/類
/**
 * Adds a path to a given parent node. Also updates the given model.
 *
 * @param parent
 *            The parent node.
 * @param dirPath
 *            The node name split by package separator.
 * @param cn
 *            The ClassNode.
 * @param model
 *            Model to add node to.
 */
public static ASMTreeNode generateTreePath(ASMTreeNode parent, List<String> dirPath, ClassNode cn, DefaultTreeModel model) {
	ASMTreeNode ret = null;
	while (dirPath.size() > 0) {
		String section = dirPath.get(0);
		ASMTreeNode node;
		// Create child if it doesn't exist.
		if ((node = parent.getChild(section)) == null) {
			ASMTreeNode newDir = ret = new ASMTreeNode(section, dirPath.size() == 1 ? cn : null);
			parent.addChild(section, newDir);
			parent.add(newDir);
			// update model
			model.nodesWereInserted(parent, new int[] { parent.getIndex(newDir) });
			node = newDir;
		}
		parent = node;
		dirPath.remove(0);
	}
	return ret;
}
 
開發者ID:Col-E,項目名稱:Recaf,代碼行數:32,代碼來源:Swing.java

示例2: circuitChanged

import javax.swing.tree.DefaultTreeModel; //導入方法依賴的package包/類
@Override
public void circuitChanged(CircuitEvent event) {
	int action = event.getAction();
	DefaultTreeModel model = (DefaultTreeModel) getModel();
	if (action == CircuitEvent.ACTION_SET_NAME) {
		model.nodeChanged(this);
	} else {
		if (computeChildren()) {
			model.nodeStructureChanged(this);
		} else if (action == CircuitEvent.ACTION_INVALIDATE) {
			Object o = event.getData();
			for (int i = children.size() - 1; i >= 0; i--) {
				Object o2 = children.get(i);
				if (o2 instanceof ComponentNode) {
					ComponentNode n = (ComponentNode) o2;
					if (n.comp == o) {
						int[] changed = { i };
						children.remove(i);
						model.nodesWereRemoved(this, changed, new Object[] { n });
						children.add(i, new ComponentNode(this, n.comp));
						model.nodesWereInserted(this, changed);
					}
				}
			}
		}
	}
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:28,代碼來源:ComponentSelector.java

示例3: ElistTablePanel

import javax.swing.tree.DefaultTreeModel; //導入方法依賴的package包/類
public ElistTablePanel(GUIFramework framework, Qualifier qualifier) {
    leafIcon = new ImageIcon(getClass().getResource(
            "/com/ramussoft/gui/table/sheet.png"));
    folderIcon = new ImageIcon(getClass().getResource(
            "/com/ramussoft/gui/table/folder.png"));
    folderSheetIcon = new ImageIcon(getClass().getResource(
            "/com/ramussoft/gui/table/folder-sheet.png"));
    setRootVisible(false);
    List<Attribute> list = qualifier.getAttributes();
    if (list.size() > 0)
        attribute = list.get(0);
    for (Attribute attr : list) {
        if (attr.getId() == qualifier.getAttributeForName()) {
            attribute = attr;
            break;
        }
    }
    Attribute[] attributes;
    if (attribute != null)
        attributes = new Attribute[]{attribute};
    else
        attributes = new Attribute[]{};
    rowSet = new RowSet(framework.getEngine(), qualifier, attributes) {

        @Override
        protected void removedFromChildren(Row parentRow, Row row, int i) {
            try {
                model.nodesWereRemoved(parentRow, new int[]{i},
                        new Object[]{row});
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        @Override
        protected void added(Row parent, final Row row, int index) {
            super.added(parent, row, index);
            if (parent == null)
                parent = getRoot();
            try {
                model.nodesWereInserted(parent, new int[]{index});
                expandPath(new TreePath(model.getPathToRoot(parent)));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        @Override
        protected void attributeChanged(Row row, Attribute attr,
                                        Object newValue, Object oldValue, boolean journaled) {
            if (attribute.getId() == attr.getId()) {
                try {
                    model.nodeChanged(row);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    };

    model = new DefaultTreeModel(rowSet.getRoot());
    setModel(model);
    for (int i = 0; i < getRowCount(); i++)
        expandRow(i);
    setRowHeight(ElistTableTabView.CELL_BORDER);
    this.addMouseMotionListener(new MouseMotionAdapter() {
        @Override
        public void mouseMoved(MouseEvent e) {
            setToolTipText(getToolTipText(e));
        }
    });

    setCellRenderer(renderer);
}
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:75,代碼來源:ElistTablePanel.java


注:本文中的javax.swing.tree.DefaultTreeModel.nodesWereInserted方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。