List of usage examples for javax.swing.tree DefaultTreeModel insertNodeInto
public void insertNodeInto(MutableTreeNode newChild, MutableTreeNode parent, int index)
From source file:it.unibas.spicygui.controllo.window.operator.ProjectTreeGenerator.java
private void analisiRicorsivaAggiuntaTC(Object root, Scenario scenario, DefaultTreeModel model, TopComponent topComponentAdded) { int indice = model.getChildCount(root); for (int i = 0; i < indice; i++) { analisiRicorsivaAggiuntaTC(model.getChild(root, i), scenario, model, topComponentAdded); }// w w w .j a va 2s . co m // if (indice == 2) { TreeTopComponentAdapter componentAdapter = (TreeTopComponentAdapter) ((DefaultMutableTreeNode) root) .getUserObject(); TopComponent tc = componentAdapter.getTopComponent(); if (tc != null && tc == scenario.getMappingTaskTopComponent()) { TreeNode treeNode = (TreeNode) root; int place = model.getChildCount(treeNode.getParent()); DefaultMutableTreeNode newNode = new DefaultMutableTreeNode( new TreeTopComponentAdapter(topComponentAdded, false, false, false)); model.insertNodeInto(newNode, (DefaultMutableTreeNode) treeNode.getParent(), place); } // return; // } }
From source file:it.unibas.spicygui.controllo.window.operator.ProjectTreeGenerator.java
private void analisiRicorsivaAggiuntaIstanza(Object root, Scenario scenario, DefaultTreeModel model, String stringa) {// w w w .j a v a 2 s . co m int indice = model.getChildCount(root); for (int i = 0; i < indice; i++) { analisiRicorsivaAggiuntaIstanza(model.getChild(root, i), scenario, model, stringa); } // if (indice == 2) { TreeTopComponentAdapter componentAdapter = (TreeTopComponentAdapter) ((DefaultMutableTreeNode) root) .getUserObject(); TopComponent tc = componentAdapter.getTopComponent(); if (tc != null && tc == scenario.getMappingTaskTopComponent()) { TreeTopComponentAdapter ttca = new TreeTopComponentAdapter(null, false, false, true); DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(ttca); TreeNode treeNode = ((TreeNode) root).getParent(); TreeNode nodeInstancesFather = treeNode.getChildAt(2); // if (stringa.equals(Costanti.SOURCE)) { TreeNode nodeInstacesSource = nodeInstancesFather.getChildAt(0); TreeNode nodeInstacesTarget = nodeInstancesFather.getChildAt(1); List<String> sourceInstancesName = (List<String>) scenario.getMappingTask().getSourceProxy() .getAnnotation(SpicyEngineConstants.XML_INSTANCE_FILE_LIST); List<String> targetInstancesName = (List<String>) scenario.getMappingTask().getTargetProxy() .getAnnotation(SpicyEngineConstants.XML_INSTANCE_FILE_LIST); int place = 0; String name = "xxx"; if (sourceInstancesName.size() != nodeInstacesSource.getChildCount()) { place = nodeInstacesSource.getChildCount(); name = findTitle(sourceInstancesName.get(sourceInstancesName.size() - 1)); model.insertNodeInto(newNode, (DefaultMutableTreeNode) nodeInstacesSource, place); } else if (targetInstancesName.size() != nodeInstacesTarget.getChildCount()) { place = nodeInstacesTarget.getChildCount(); name = findTitle(targetInstancesName.get(targetInstancesName.size() - 1)); model.insertNodeInto(newNode, (DefaultMutableTreeNode) nodeInstacesTarget, place); } ttca.setName(name); scenario.getXQueryTopComponent().update(); // return; // } } // return; // } }
From source file:com.SE.myPlayer.MusicPlayerGUI.java
private void treeReferesh() { DefaultTreeModel myModel = (DefaultTreeModel) folder_Playlist_Tree.getModel(); DefaultMutableTreeNode root = (DefaultMutableTreeNode) myModel.getRoot(); root.removeAllChildren();/*from w ww. ja v a2 s. c o m*/ DefaultMutableTreeNode library = new DefaultMutableTreeNode("library"); DefaultMutableTreeNode playlist = new DefaultMutableTreeNode("playlist"); myModel.insertNodeInto(library, root, root.getChildCount()); myModel.insertNodeInto(playlist, root, root.getChildCount()); try { con = db.getCon(); stmt = con.createStatement(); String node; ResultSet rs = stmt.executeQuery("select pn_name from playlist_name"); while (rs.next()) { node = rs.getString(1); DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(node); myModel.insertNodeInto(newNode, playlist, playlist.getChildCount()); } if (con != null) { stmt.close(); con.close(); } } catch (SQLException e) { System.out.println("Error in Stmt " + e); } myModel.reload(); folder_Playlist_Tree.setModel(myModel); }
From source file:edu.ku.brc.af.tasks.subpane.formeditor.ViewSetSelectorPanel.java
/** * Adds a new row in the right position (above). *//*from ww w .j a v a 2 s. com*/ protected void addRow() { DefaultTreeModel model = (DefaultTreeModel) tree.getModel(); FormRow newRow = new FormRow(); DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(newRow); newNode.setUserObject(newRow); DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) tree.getSelectionModel().getSelectionPath() .getLastPathComponent(); DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) selectedNode.getParent(); if (parentNode == null) { parentNode = (DefaultMutableTreeNode) model.getRoot(); selectedNode = null; } int position; if (selectedRow == null || parentNode.getUserObject() instanceof String) { formViewDef.getRows().add(newRow); position = formViewDef.getRows().size() - 1; } else { position = formViewDef.getRows().indexOf(selectedRow); formViewDef.getRows().insertElementAt(newRow, (byte) position); } model.insertNodeInto(newNode, parentNode, position); renumberRows(formViewDef.getRows()); updateTreeNodes((DefaultMutableTreeNode) model.getRoot(), model, false); Object[] newPath = new Object[2]; newPath[0] = parentNode; newPath[1] = newNode; final TreePath newTreePath = new TreePath(newPath); SwingUtilities.invokeLater(new Runnable() { public void run() { tree.setSelectionPath(newTreePath); } }); previewPanel.rebuild(false); }
From source file:eu.crisis_economics.abm.dashboard.Page_Parameters.java
private void addSubParametersToTree(final SubmodelInfo sInfo, final JTree tree, final DefaultMutableTreeNode node) { try {/*from ww w. j a va 2 s . com*/ final List<ai.aitia.meme.paramsweep.batch.param.ParameterInfo<?>> subparameters = ParameterTreeUtils .fetchSubparameters(currentModelHandler, sInfo); final List<ParameterInfo> convertedSubparameters = new ArrayList<ParameterInfo>(subparameters.size()); for (ai.aitia.meme.paramsweep.batch.param.ParameterInfo<?> parameterInfo : subparameters) { final ParameterInfo converted = InfoConverter.parameterInfo2ParameterInfo(parameterInfo); converted.setRuns(0); convertedSubparameters.add(converted); } Collections.sort(convertedSubparameters); final DefaultTreeModel treeModel = (DefaultTreeModel) tree.getModel(); if (node.getChildCount() > 0) { node.removeAllChildren(); treeModel.nodeStructureChanged(node); } for (final ParameterInfo pInfo : convertedSubparameters) { final DefaultMutableTreeNode newNode = new DefaultMutableTreeNode( new ParameterInATree(pInfo, currentModelHandler.getModelClass())); treeModel.insertNodeInto(newNode, node, node.getChildCount()); if (pInfo instanceof SubmodelInfo) { final SubmodelInfo ssInfo = (SubmodelInfo) pInfo; if (ssInfo.getActualType() != null) addSubParametersToTree(ssInfo, tree, newNode); } } //tree.expandPath(new TreePath(treeModel.getPathToRoot(node))); } catch (final ModelInformationException e) { sInfo.setActualType(null, null); JOptionPane.showMessageDialog(wizard, new JLabel(e.getMessage()), "Error while analyizing model", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); submodelTypeBox.setSelectedIndex(0); } }
From source file:eu.crisis_economics.abm.dashboard.Page_Parameters.java
private void addParameterToTree(final AvailableParameter[] parameters, final ParameterCombinationGUI pcGUI) { final DefaultListModel listModel = (DefaultListModel) parameterList.getModel(); final DefaultTreeModel treeModel = (DefaultTreeModel) pcGUI.tree.getModel(); final DefaultMutableTreeNode root = (DefaultMutableTreeNode) treeModel.getRoot(); for (final AvailableParameter parameter : parameters) { listModel.removeElement(parameter); final ParameterInfo selectedInfo = parameter.info; final DefaultMutableTreeNode newNode = new DefaultMutableTreeNode( new ParameterInATree(selectedInfo, currentModelHandler.getModelClass())); treeModel.insertNodeInto(newNode, root, root.getChildCount()); if (selectedInfo instanceof SubmodelInfo) { final SubmodelInfo sInfo = (SubmodelInfo) selectedInfo; if (sInfo.getActualType() != null) { addSubParametersToTree(sInfo, pcGUI.tree, newNode); pcGUI.tree.expandPath(new TreePath(treeModel.getPathToRoot(newNode))); }/*from ww w.j av a2 s . co m*/ } } updateNumberOfRuns(); pcGUI.tree.expandPath(new TreePath(treeModel.getPathToRoot(root))); }
From source file:eu.crisis_economics.abm.dashboard.Page_Parameters.java
private JPanel createAParameterBox(final boolean first) { final JLabel runLabel = new JLabel("<html><b>Number of runs:</b> 0</html>"); final JLabel warningLabel = new JLabel(); final JButton closeButton = new JButton(); closeButton.setOpaque(false);/*from w ww.j a va 2 s . c om*/ closeButton.setBorder(null); closeButton.setFocusable(false); if (!first) { closeButton.setRolloverIcon(PARAMETER_BOX_REMOVE); closeButton.setRolloverEnabled(true); closeButton.setIcon(RGBGrayFilter.getDisabledIcon(closeButton, PARAMETER_BOX_REMOVE)); closeButton.setActionCommand(ACTIONCOMMAND_REMOVE_BOX); } final JScrollPane treeScrPane = new JScrollPane(); final DefaultMutableTreeNode treeRoot = new DefaultMutableTreeNode(); final JTree tree = new JTree(treeRoot); ToolTipManager.sharedInstance().registerComponent(tree); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); tree.setCellRenderer(new ParameterBoxTreeRenderer()); tree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(final TreeSelectionEvent e) { final TreePath selectionPath = tree.getSelectionPath(); boolean success = true; if (editedNode != null && (selectionPath == null || !editedNode.equals(selectionPath.getLastPathComponent()))) success = modify(); if (success) { if (selectionPath != null) { cancelAllSelectionBut(tree); final DefaultMutableTreeNode node = (DefaultMutableTreeNode) selectionPath .getLastPathComponent(); if (!node.equals(editedNode)) { ParameterInATree userObj = null; final DefaultTreeModel model = (DefaultTreeModel) tree.getModel(); if (!node.isRoot() && selectionPath.getPathCount() == model.getPathToRoot(node).length) { userObj = (ParameterInATree) node.getUserObject(); final ParameterInfo info = userObj.info; editedNode = node; editedTree = tree; edit(info); } else { tree.setSelectionPath(null); if (cancelButton.isEnabled()) cancelButton.doClick(); resetSettings(); enableDisableSettings(false); editedNode = null; editedTree = null; } updateDescriptionField(userObj); } else updateDescriptionField(); } else updateDescriptionField(); enableDisableParameterCombinationButtons(); } else { final DefaultTreeModel model = (DefaultTreeModel) editedTree.getModel(); final DefaultMutableTreeNode storedEditedNode = editedNode; editedNode = null; tree.setSelectionPath(null); editedNode = storedEditedNode; editedTree.setSelectionPath(new TreePath(model.getPathToRoot(editedNode))); } } }); treeScrPane.setViewportView(tree); treeScrPane.setBorder(null); treeScrPane.setViewportBorder(null); treeScrPane.setPreferredSize(new Dimension(450, 250)); final JButton upButton = new JButton(); upButton.setOpaque(false); upButton.setRolloverEnabled(true); upButton.setIcon(PARAMETER_UP_ICON); upButton.setRolloverIcon(PARAMETER_UP_ICON_RO); upButton.setDisabledIcon(PARAMETER_UP_ICON_DIS); upButton.setBorder(null); upButton.setToolTipText("Move up the selected parameter"); upButton.setActionCommand(ACTIONCOMMAND_MOVE_UP); final JButton downButton = new JButton(); downButton.setOpaque(false); downButton.setRolloverEnabled(true); downButton.setIcon(PARAMETER_DOWN_ICON); downButton.setRolloverIcon(PARAMETER_DOWN_ICON_RO); downButton.setDisabledIcon(PARAMETER_DOWN_ICON_DIS); downButton.setBorder(null); downButton.setToolTipText("Move down the selected parameter"); downButton.setActionCommand(ACTIONCOMMAND_MOVE_DOWN); final JPanel mainPanel = FormsUtils.build("~ f:p:g ~ p ~ r:p", "012||" + "333||" + "44_||" + "445||" + "446||" + "44_ f:p:g", runLabel, first ? "" : warningLabel, first ? warningLabel : closeButton, new FormsUtils.Separator(""), treeScrPane, upButton, downButton) .getPanel(); mainPanel.setBorder(BorderFactory.createTitledBorder("")); final JButton addButton = new JButton(); addButton.setOpaque(false); addButton.setRolloverEnabled(true); addButton.setIcon(PARAMETER_ADD_ICON); addButton.setRolloverIcon(PARAMETER_ADD_ICON_RO); addButton.setDisabledIcon(PARAMETER_ADD_ICON_DIS); addButton.setBorder(null); addButton.setToolTipText("Add selected parameter"); addButton.setActionCommand(ACTIONCOMMAND_ADD_PARAM); final JButton removeButton = new JButton(); removeButton.setOpaque(false); removeButton.setRolloverEnabled(true); removeButton.setIcon(PARAMETER_REMOVE_ICON); removeButton.setRolloverIcon(PARAMETER_REMOVE_ICON_RO); removeButton.setDisabledIcon(PARAMETER_REMOVE_ICON_DIS); removeButton.setBorder(null); removeButton.setToolTipText("Remove selected parameter"); removeButton.setActionCommand(ACTIONCOMMAND_REMOVE_PARAM); final JPanel result = FormsUtils.build("p ~ f:p:g", "_0 f:p:g||" + "10 p ||" + "20 p||" + "_0 f:p:g", mainPanel, addButton, removeButton).getPanel(); Style.registerCssClasses(result, Dashboard.CSS_CLASS_COMMON_PANEL); final ParameterCombinationGUI pcGUI = new ParameterCombinationGUI(tree, treeRoot, runLabel, warningLabel, addButton, removeButton, upButton, downButton); parameterTreeBranches.add(pcGUI); final ActionListener boxActionListener = new ActionListener() { //==================================================================================================== // methods //---------------------------------------------------------------------------------------------------- public void actionPerformed(final ActionEvent e) { final String cmd = e.getActionCommand(); if (ACTIONCOMMAND_ADD_PARAM.equals(cmd)) handleAddParameter(pcGUI); else if (ACTIONCOMMAND_REMOVE_PARAM.equals(cmd)) handleRemoveParameter(tree); else if (ACTIONCOMMAND_REMOVE_BOX.equals(cmd)) handleRemoveBox(tree); else if (ACTIONCOMMAND_MOVE_UP.equals(cmd)) handleMoveUp(); else if (ACTIONCOMMAND_MOVE_DOWN.equals(cmd)) handleMoveDown(); } //---------------------------------------------------------------------------------------------------- private void handleAddParameter(final ParameterCombinationGUI pcGUI) { final Object[] selectedValues = parameterList.getSelectedValues(); if (selectedValues != null && selectedValues.length > 0) { final AvailableParameter[] params = new AvailableParameter[selectedValues.length]; System.arraycopy(selectedValues, 0, params, 0, selectedValues.length); addParameterToTree(params, pcGUI); enableDisableParameterCombinationButtons(); } } //---------------------------------------------------------------------------------------------------- private void handleRemoveParameter(final JTree tree) { final TreePath selectionPath = tree.getSelectionPath(); if (selectionPath != null) { cancelButton.doClick(); final DefaultMutableTreeNode node = (DefaultMutableTreeNode) selectionPath .getLastPathComponent(); if (!node.isRoot()) { final DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) node.getParent(); if (parentNode.isRoot()) { removeParameter(tree, node, parentNode); enableDisableParameterCombinationButtons(); } } } } //---------------------------------------------------------------------------------------------------- private void handleRemoveBox(final JTree tree) { final int answer = Utilities.askUser(dashboard, false, "Comfirmation", "This operation deletes the combination.", "All related parameter returns back to the list on the left side.", "Are you sure?"); if (answer == 1) { final DefaultTreeModel treeModel = (DefaultTreeModel) tree.getModel(); if (tree.getSelectionCount() > 0) { editedNode = null; tree.setSelectionPath(null); if (cancelButton.isEnabled()) cancelButton.doClick(); } final DefaultMutableTreeNode root = (DefaultMutableTreeNode) treeModel.getRoot(); for (int i = 0; i < root.getChildCount(); ++i) { final DefaultMutableTreeNode node = (DefaultMutableTreeNode) root.getChildAt(i); removeParameter(tree, node, root); } enableDisableParameterCombinationButtons(); parameterTreeBranches.remove(pcGUI); combinationsPanel.remove(result); combinationsPanel.revalidate(); updateNumberOfRuns(); } } //---------------------------------------------------------------------------------------------------- private void removeParameter(final JTree tree, final DefaultMutableTreeNode node, final DefaultMutableTreeNode parentNode) { final ParameterInATree userObj = (ParameterInATree) node.getUserObject(); final ParameterInfo originalInfo = findOriginalInfo(userObj.info); if (originalInfo != null) { final DefaultListModel model = (DefaultListModel) parameterList.getModel(); model.addElement(new AvailableParameter(originalInfo, currentModelHandler.getModelClass())); final DefaultTreeModel treeModel = (DefaultTreeModel) tree.getModel(); treeModel.removeNodeFromParent(node); updateNumberOfRuns(); tree.expandPath(new TreePath(treeModel.getPathToRoot(parentNode))); } else throw new IllegalStateException( "Parameter " + userObj.info.getName() + " is not found in the model."); } //---------------------------------------------------------------------------------------------------- private void handleMoveUp() { final TreePath selectionPath = tree.getSelectionPath(); if (selectionPath != null) { boolean success = true; if (editedNode != null) success = modify(); if (success) { final DefaultMutableTreeNode node = (DefaultMutableTreeNode) selectionPath .getLastPathComponent(); final DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent(); if (parent == null || parent.getFirstChild().equals(node)) { tree.setSelectionPath(null); // we need this to preserve the state of the parameter settings panel tree.setSelectionPath(new TreePath(node.getPath())); return; } final int index = parent.getIndex(node); final DefaultTreeModel treemodel = (DefaultTreeModel) tree.getModel(); treemodel.removeNodeFromParent(node); treemodel.insertNodeInto(node, parent, index - 1); tree.setSelectionPath(new TreePath(node.getPath())); } } } //---------------------------------------------------------------------------------------------------- private void handleMoveDown() { final TreePath selectionPath = tree.getSelectionPath(); if (selectionPath != null) { boolean success = true; if (editedNode != null) success = modify(); if (success) { final DefaultMutableTreeNode node = (DefaultMutableTreeNode) selectionPath .getLastPathComponent(); final DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent(); if (parent == null || parent.getLastChild().equals(node)) { tree.setSelectionPath(null); // we need this to preserve the state of the parameter settings panel tree.setSelectionPath(new TreePath(node.getPath())); return; } final int index = parent.getIndex(node); final DefaultTreeModel treemodel = (DefaultTreeModel) tree.getModel(); treemodel.removeNodeFromParent(node); treemodel.insertNodeInto(node, parent, index + 1); tree.setSelectionPath(new TreePath(node.getPath())); } } } }; GUIUtils.addActionListener(boxActionListener, closeButton, upButton, downButton, addButton, removeButton); result.setPreferredSize(new Dimension(500, 250)); enableDisableParameterCombinationButtons(); Style.apply(result, dashboard.getCssStyle()); return result; }
From source file:src.gui.ItSIMPLE.java
public void updateNewDomainProjectParallelTree(DefaultTreeModel treeModel, Element domain, ItTreeNode selectedNode) {/*from w ww .j ava2s .c o m*/ ItTreeNode problemsTreeProjectNode = (ItTreeNode) ((ItTreeNode) treeModel.getRoot()) .getChildAt(treeRoot.getIndex(selectedNode)); ItTreeNode problemsTreeDomainNode = new ItTreeNode(domain.getChildText("name"), domain, null, null); problemsTreeDomainNode.setIcon(new ImageIcon("resources/images/domain.png")); treeModel.insertNodeInto(problemsTreeDomainNode, problemsTreeProjectNode, problemsTreeProjectNode.getChildCount()); List<?> problems = domain.getChild("planningProblems").getChildren("problem"); for (Iterator<?> iterator = problems.iterator(); iterator.hasNext();) { Element problem = (Element) iterator.next(); ItTreeNode planProblemNode = new ItTreeNode(problem.getChildText("name"), problem, null, null); planProblemNode.setIcon(new ImageIcon("resources/images/planningProblem.png")); treeModel.insertNodeInto(planProblemNode, problemsTreeDomainNode, problemsTreeDomainNode.getChildCount()); } }
From source file:src.gui.ItSIMPLE.java
/** * This method updates any parallel tree (e.g., planning, analysis) when a new project is opened or created * @param doc// w ww . j a va 2s . co m * @param xmlRoot * @param newProjectNode */ public void updateNewProjectParallelTree(DefaultTreeModel treeModel, JTree tree, Document doc, Element xmlRoot, ItTreeNode newProjectNode) { // plan simulation problem tree ItTreeNode problemsPlanTreeRoot = (ItTreeNode) treeModel.getRoot(); //opening //ItTreeNode planProjectNode = (ItTreeNode)newProjectNode.clone(); //new project //ItTreeNode planProjectNode = new ItTreeNode(xmlRoot.getChildText("name"), xmlRoot, null, null); ItTreeNode planProjectNode = newProjectNode; planProjectNode.setIcon(new ImageIcon("resources/images/project.png")); treeModel.insertNodeInto(planProjectNode, problemsPlanTreeRoot, problemsPlanTreeRoot.getChildCount()); //check if this is a UML project if (xmlRoot.getName().equals("project")) { List<?> domains = doc.getRootElement().getChild("diagrams").getChild("planningDomains") .getChildren("domain"); for (Iterator<?> iter = domains.iterator(); iter.hasNext();) { Element domain = (Element) iter.next(); ItTreeNode planDomainNode = new ItTreeNode(domain.getChildText("name"), domain, null, null); planDomainNode.setIcon(new ImageIcon("resources/images/domain.png")); treeModel.insertNodeInto(planDomainNode, planProjectNode, planProjectNode.getChildCount()); List<?> problems = domain.getChild("planningProblems").getChildren("problem"); for (Iterator<?> iterator = problems.iterator(); iterator.hasNext();) { Element problem = (Element) iterator.next(); ItTreeNode planProblemNode = new ItTreeNode(problem.getChildText("name"), problem, null, null); planProblemNode.setIcon(new ImageIcon("resources/images/planningProblem.png")); treeModel.insertNodeInto(planProblemNode, planDomainNode, planDomainNode.getChildCount()); } } } //check if this is a PDDL project else if (xmlRoot.getName().equals("pddlproject")) { List<?> problems = doc.getRootElement().getChild("problemInstances").getChildren("pddlproblem"); for (Iterator<?> iter = problems.iterator(); iter.hasNext();) { Element problem = (Element) iter.next(); ItTreeNode planpddlProblemNode = new ItTreeNode(problem.getChildText("name"), problem, null, null); planpddlProblemNode.setIcon(new ImageIcon("resources/images/domain.png")); treeModel.insertNodeInto(planpddlProblemNode, planProjectNode, planProjectNode.getChildCount()); } } tree.expandRow(0); }
From source file:src.gui.ItSIMPLE.java
public void updateNewProblemProjectParallelTree(DefaultTreeModel treeModel, Element problem, ItTreeNode selectedNode, ItTreeNode project) { ItTreeNode problemsTreeProject = (ItTreeNode) ((ItTreeNode) treeModel.getRoot()) .getChildAt(treeRoot.getIndex(project)); //selectedNode.getParent() ItTreeNode problemsTreeDomain = null; // look for the domain in problems plan tree for (int i = 0; i < problemsTreeProject.getChildCount(); i++) { ItTreeNode child = (ItTreeNode) problemsTreeProject.getChildAt(i); if (child.getData() == selectedNode.getData()) { problemsTreeDomain = child;//from w ww .j ava2s . c o m break; } } if (problemsTreeDomain != null) { ItTreeNode problemsTreeProblem = new ItTreeNode(problem.getChildText("name"), problem, null, null); problemsTreeProblem.setIcon(new ImageIcon("resources/images/planningProblem.png")); treeModel.insertNodeInto(problemsTreeProblem, problemsTreeDomain, problemsTreeDomain.getChildCount()); } }