private void LoadUpTree() {
    //DefaultTreeModel model = new DefaultTreeModel("root");
    
    DefaultMutableTreeNode root = new DefaultMutableTreeNode(selectedProject) ;
    DefaultTreeModel treeModel = new DefaultTreeModel(root);
    
    DefaultMutableTreeNode elementNode = null;
    DefaultMutableTreeNode assetNode = null;
    DefaultMutableTreeNode taskNode = null;
    
    
    //For loop to get all elements
    //within that get all assets
    //within that get tasks for the assets
    //SetOfElements setOfElement = selectedProject.getElementCollection();
    
    try{
                ResultSet elementsOnProjectListResultSet = null;
                Statement ElementStatement;
                ElementStatement = connection.createStatement();
                elementsOnProjectListResultSet = ElementStatement.executeQuery("SELECT Element.elementID, Element.elementName, SetOFElements.ProjectID FROM Element INNER JOIN SetOFElements ON Element.[elementID] = SetOFElements.[elementID] WHERE ProjectID="+ selectedProject.getProjectID() +";"); 
                int elementID;
                String elementName;

                while(elementsOnProjectListResultSet.next())
                {
                    elementID = elementsOnProjectListResultSet.getInt("elementID");
                    elementName = elementsOnProjectListResultSet.getString("elementName");
                    Element element = new Element(elementID,elementName);
                    elementNode = new DefaultMutableTreeNode(element);
                    
                     Statement AssetStatement;
                    ElementStatement = connection.createStatement();
                    ResultSet assetsOnElementsListResultSet = null;
                    AssetStatement = connection.createStatement();
                    assetsOnElementsListResultSet = AssetStatement.executeQuery("SELECT Asset.ID,Asset.assetName, Asset.assetType, SetOFAssets.elementID" +
                                                " FROM Asset LEFT JOIN SetOFAssets ON Asset.ID = SetOFAssets.assetID" +
                                                " WHERE (((SetOFAssets.elementID) = " + elementID  + " ));");
                    int assetID;
                    String assetName;      
                    String assetType; 
                    SetOfTasks assetTasks = new SetOfTasks();

                    while(assetsOnElementsListResultSet.next()){
                        assetID = assetsOnElementsListResultSet.getInt("ID");
                        assetName = assetsOnElementsListResultSet.getString("assetName");
                        assetType = assetsOnElementsListResultSet.getString("assetType");                      
                        Asset newAsset = new Asset(assetID, assetName, assetType, assetTasks);
                       
                        assetNode = new DefaultMutableTreeNode(newAsset);
                     
                         Statement TaskStatement;
                         TaskStatement = connection.createStatement();
                         ResultSet tasksOnAssetListResultSet = null;
                         tasksOnAssetListResultSet = TaskStatement.executeQuery("SELECT * FROM Task WHERE assetID = " + newAsset.getAssetID() + ";");  
                         randSQL.loadAllUsers();
                         SetOfUsers allusers = randSQL.getAllUsers();

                        while (tasksOnAssetListResultSet.next()){
                            int taskID;
                            int projectID;                        
                            User responsible = null;
                            int taskPriority;
                            String status;
                            String taskName;
                            String taskType;
                            taskID = tasksOnAssetListResultSet.getInt("taskID");
                            projectID = tasksOnAssetListResultSet.getInt("projectID");
   
                            for(int i=0; i<allusers.size();i++){
                                if(tasksOnAssetListResultSet.getInt("responsiblePerson")==allusers.get(i).getUserID());
                                {
                                    responsible = allusers.get(i);
                                    break;
                                }     
                             }                 
                              taskPriority = tasksOnAssetListResultSet.getInt("taskPriority");
                              status = tasksOnAssetListResultSet.getString("status");
                              taskName = tasksOnAssetListResultSet.getString("taskName");
                              taskType = tasksOnAssetListResultSet.getString("type");                   
                              Task newTask = new Task(taskID, responsible,taskName, taskPriority , status,projectID, newAsset, taskType);                     
                                            
                               taskNode = new DefaultMutableTreeNode(newTask);
                               newAsset.getSetOfTasks().add(newTask);
                               assetNode.add(taskNode);
                         }                     

                     elementNode.add(assetNode);
                    }
                    
                    
                    TreeRenderer renderer = new TreeRenderer();
                    jTree1.setCellRenderer(renderer);
                    treeModel.insertNodeInto(elementNode, root, root.getChildCount());
                  
                     //AssetsListCellRenderer renderer = new AssetsListCellRenderer();  //custom cell renderer to display property rather than useless object.toString()
            //listAssetList.setCellRenderer(renderer);  

                }
            }catch(SQLException err)
                    {
                        System.out.println("ERROR: " + err);
                        JOptionPane.showMessageDialog(null,"* Cannot connect to database! *");
                        System.exit(1);
                    }

    
     jTree1.setModel(treeModel);
    }