Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

refresh JTree

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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.
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Reload the parent node. It'll be refreshed
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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)
{
}
}
};
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
This thread is from 2001. Typically, it's pointless to raise these old posts from the dead. I'm going to just close it.
 
permaculture is largely about replacing oil with people. And one tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
    Bookmark Topic Watch Topic
  • New Topic