Hi all , i am running to a problem , maybe one of you can find the problem .
i have a JTree , and i want to update him in a Thread , since i want it to change the progress bar .
i used the Netbeans progress bar .
everything works fine , my only problem is , that once the Task is done , i see the JTree return to be empty .
and not saving the root i add in the succeeded function .
the code :
// this is the button i press to add to start the Task @Action public Task AddToList(){ Task newTask = new runThreadFolderBrowser(getApplication()); return newTask; } private class runThreadFolderBrowser extends org.jdesktop.application.Task<Object, Void> { private DefaultMutableTreeNode saveTreeNode; // <editor-fold defaultstate="collapsed" desc="Constructor of the Class"> runThreadFolderBrowser(org.jdesktop.application.Application app){ // the Constructor Runs on EDT , and can Update the GUI super(app); treeComponents.setEditable(true); } @Override protected Object doInBackground(){ CheckListItem[] allFoldersItems = BackupServerSettings.Instance.researchBackupFolder(); DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("Backup Server"); try { succeeded(rootNode); return null; } catch ( NullPointerException noFolder_noConnection){ return null; } } @Override protected void succeeded(Object rootNode){ DefaultTreeModel treemodel = (DefaultTreeModel) treeComponents.getModel(); // get the current JTree treemodel.setRoot((DefaultMutableTreeNode)rootNode); // change the Root folders of the current tree . treeComponents.setRootVisible(true); treeComponents.repaint(); // repaint the JTree } @Override protected void finished(){ } }