DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode)newChildren[i]; ConsoleTreeObject cto = (ConsoleTreeObject)treeNode.getUserObject(); AgentComponent agentComponent = (AgentComponent)cto.getComponent(); if (!nodeComponentHasAgent(nodeComponent, agentComponent)) nodeComponent.addAgent(agentComponent);
AgentComponent agentComponent = (AgentComponent)getComponentFromTreeNode((DefaultMutableTreeNode)newChildren[i]); NodeComponent previousParent = (NodeComponent)agentToNode.get(agentComponent);  if (previousParent != null && previousParent.equals(nodeComponent)) return; nodeComponent.addAgent(agentComponent); if (previousParent != null) previousParent.removeAgent(agentComponent); agentToNode.put(agentComponent, nodeComponent);
  private void addAgentsToNode(NodeComponent nodeComponent,			       Object[] newChildren) {    for (int i = 0; i < newChildren.length; i++) {      DefaultMutableTreeNode treeNode =	(DefaultMutableTreeNode)newChildren[i];      ConsoleTreeObject cto = (ConsoleTreeObject)treeNode.getUserObject();      AgentComponent agentComponent = (AgentComponent)cto.getComponent();      if (!nodeComponentHasAgent(nodeComponent, agentComponent))	nodeComponent.addAgent(agentComponent);    }  }