当前位置: 首页>>代码示例>>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;未经允许,请勿转载。