This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes refresh JTree Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply locked New topic
Author

refresh JTree

teddy
Greenhorn

Joined: Jun 08, 2001
Posts: 2
Hi,
I've a JTree; while I delete a node from it, I've the JTree with two parts separated with a blank (transparent or whole) line. I've try all methods to refresh the JTree but nothing done.
have you a suggestion ? it's very important !!!
thanks,
ted
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Teddy,
How are you deleting the node. If you use the DefaultModel method removeNodeFromParent you will have no problem.
treeModel.removeNodeFromParent(currentNode);
Regards,
Manfred.
Swamy Vatti
Ranch Hand

Joined: May 02, 2001
Posts: 57
Reload the parent node. It'll be refreshed


Swamy
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

teddy,

Please re-register with a name that follows the guidelines of the JavaRanch naming conventions. We require all registered user names to be in the form "first name" + space + "last name". Thanks!

-Nate


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
krish rajini
Greenhorn

Joined: Jul 02, 2008
Posts: 25
Action a1 = new AbstractAction("Delete")
{
public void actionPerformed(ActionEvent e)
{
try
{
String succ=null;
m_model = (DefaultTreeModel)m_tree.getModel();
DefaultMutableTreeNode node = (DefaultMutableTreeNode)m_tree.getLastSelectedPathComponent();
String str=node.getUserObject().toString();
p1 = m_tree.getNextMatch(str, 0, Position.Bias.Forward);
System.out.println("DDDDDDDD "+p1);
DefaultMutableTreeNode no = getTreeNode(p1);
FileNode fnode = getFileNode(no);
if (fnode != null)
succ=fnode.getFile().getAbsolutePath();
File f=new File(succ);
if(f.isFile())
{
boolean b=f.delete();
System.out.println(b);
if(b==true)
{
mNode = (MutableTreeNode)p1.getLastPathComponent();
m_model.removeNodeFromParent(mNode);
JOptionPane.showMessageDialog(null, "Node are deleted from tree!");
}
}
else
{
System.out.println(f.getAbsolutePath());
listFilesAndFolders(f.getAbsolutePath());
f.delete();
mNode = (MutableTreeNode)p1.getLastPathComponent();
m_model.removeNodeFromParent(mNode);
JOptionPane.showMessageDialog(null, "Node are deleted from tree!");
}
}
catch(Exception ae)
{
}
}
};
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

This thread is from 2001. Typically, it's pointless to raise these old posts from the dead. I'm going to just close it.


GenRocket - Experts at Building Test Data
 
Consider Paul's rocket mass heater.
 
subject: refresh JTree
 
Similar Threads
JTree not repainting
JTree
Refresh JTree
Refreshing JTree
JTree in Browser