Save me!! about JTree refresh!!

Hello ereryone. I met a problem and I tried lots of method,such as reload(),validate(),revalidate(),but it seemed that they doesn't work.
My gui is about: here is a JSplitpane,on the left part ,there is a panel(borderlayou) in it. A button in the panel's west and a JScrollPane in the panel's center. A JTree component in the JScrollPane.
The wished fountion is when the program run, the tree would show the demanded disk file system(read config file to get the root file).when u click the button, a JFilechooser come out and u can choose another dir of the disk. when u click "ok", the tree should show the new file structure of the new dir.
here are 2 java file.
//myclass.java
//myclass.java
import javax.swing.*;
import javax.swing.tree.*;
import javax.swing.event.*;
import javax.swing.border.*;
import javax.swing.plaf.basic.*;
import javax.swing.ImageIcon;
import java.awt.dnd.*;
import java.awt.datatransfer.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
public class myclass extends JFrame implements WindowListener{
private JFrame f=null;
private JLabel labeladdress;
private JLabel labelstatus;
private JTree tree;
private JSplitPane splitPane;
private JEditorPane htmlPane;
private JPopupMenu Popup=null;
private DefaultTreeModel treeModel=null;
private String str="";
private boolean statusbarflag=true;
private boolean addressbarflag=true;
String currentpos;
ImageIcon icon=new ImageIcon("icons/paste.gif");
ReadAndWriteXML wp=new ReadAndWriteXML();
public WebPageSave(Vector vec) throws FileNotFoundException, SecurityException,Exception{
wp.address_Vector=new Vector();
wp.readXMLFile("sys/workposition.xml");
f=new JFrame("WebHunter");
Container contentPane=(JPanel)f.getContentPane();
contentPane.setLayout(new BorderLayout());
JPanel panel=new JPanel();
panel.setLayout(new BorderLayout());
paneln.setLayout(new BorderLayout());
contentPane.add(panel,BorderLayout.CENTER);
contentPane.add(paneln,BorderLayout.NORTH);
//添加JTree和JEditorPane
//JTree tree=new JTree();
initialtree(wp.address_Vector.get(0).toString());
final JScrollPane scrollPanel=new JScrollPane(tree);
final JPanel mainleft=new JPanel(new BorderLayout());
JButton jchange=new JButton("change position");
currentpos=wp.address_Vector.get(0).toString();
//the button anonymous class
jchange.addActionListener(new ActionListener(){   //change the dir
public void actionPerformed(ActionEvent event){
JFileChooser chooser=new JFileChooser(currentpos);
chooser.setDialogTitle("choose ur position");
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int result=chooser.showDialog(f,"ok");
if(result==JFileChooser.APPROVE_OPTION){
int i=JOptionPane.showConfirmDialog(f,"make sure?","notice",JOptionPane.YES_NO_OPTION);
if(i==JOptionPane.YES_OPTION){
try{
//ReadAndWriteXML wp=new ReadAndWriteXML();
wp.address_Vector=new Vector();
wp.readXMLFile("sys/workposition.xml");
FileOperation u=new FileOperation();
u.xcopy(wp.address_Vector.get(0).toString(),chooser.getSelectedFile().toString());
u.delete(new File(wp.address_Vector.get(0).toString()));
}catch(Exception e){
e.printStackTrace();
//write the new positon to the workposition.xml文件
try{
wp.writeXMLFile("sys/workposition.xml",chooser.getSelectedFile().toString());
}catch (Exception e) {
e.printStackTrace();
?????? //refresh tree
try{
ReadAndWriteXML wp=new ReadAndWriteXML();
wp.address_Vector=new Vector();
wp.readXMLFile("sys/workposition.xml");
currentpos=wp.address_Vector.get(0).toString();
//currentpos=chooser.getSelectedFile().toString();
//initialtree(wp.address_Vector.get(0).toString());
initialtree(chooser.getSelectedFile().toString());
//JScrollPane scrollPanel=new JScrollPane(tree);
//mainleft.add(scrollPanel,BorderLayout.CENTER);
//tree.
//mainleft.validate();
JOptionPane.showConfirmDialog(f,"change positon successfully!","notice",JOptionPane.CLOSED_OPTION);
}catch (Exception e1) {
e1.printStackTrace();
mainleft.add(scrollPanel,BorderLayout.CENTER);
mainleft.add(jchange,BorderLayout.SOUTH);
JScrollPane scrollPane2=new JScrollPane(htmlPane);
splitPane=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,true,mainleft,scrollPane2);
splitPane.setDividerSize(10);
splitPane.setDividerLocation(180);
panel.add(splitPane,BorderLayout.CENTER);
panel.add(labelstatus,BorderLayout.SOUTH);
f.pack();
f.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
f.setExtendedState(Frame.MAXIMIZED_BOTH);
f.setIconImage(icon.getImage());
//f.setBounds(0,0,1020,725);
f.show();
//f.addWindowListener(new WindowListenerHandle());
f.addWindowListener(this);
}//constructor over!!!
public void initialtree(String s) throws FileNotFoundException,SecurityException,Exception{
//ReadAndWriteXML treefile=new ReadAndWriteXML();
//treefile.address_Vector=new Vector();
//treefile.readXMLFile("sys/workposition.xml");
//tree=new FileTree(s);
//tree.revalidate();
//((DefaultTreeModel)tree.getModel()).nodeStructureChanged((DefaultTreeModel)s);
tree=new showDir().initTree(s);
tree.revalidate();
//DefaultTreeModel model=new DefaultTreeModel(tree.getModel());
//treeModel=(DefaultTreeModel) tree.getModel();
//tree.setModel(model);
//treeModel.reload();
tree.setEditable(true);
//FileTree.java
import javax.swing.*;
import javax.swing.tree.*;
import javax.swing.event.*;
import java.io.*;
import java.util.*;
public class FileTree extends JTree {
private static DefaultTreeModel model;
public FileTree(String path) throws FileNotFoundException, SecurityException {
super((TreeModel)null); // Create the JTree itself
// Use horizontal and vertical lines
putClientProperty("JTree.lineStyle", "Angled");
// Create the first node
FileTreeNode rootNode = new FileTreeNode(null, path);
model=new DefaultTreeModel(rootNode);
// Populate the root node with its subdirectories
boolean addedNodes = rootNode.populateDirectories(true);
//model.nodeStructureChanged(rootNode);
setModel(new DefaultTreeModel(rootNode));
//(new DefaultTreeModel(rootNode))this.getModel().reload();
//model.reload();
// Listen for Tree Selection Events
addTreeExpansionListener(new TreeExpansionHandler());
// Returns the full pathname for a path, or null if not a known path
public String getPathName(TreePath path) {
Object o = path.getLastPathComponent();
if (o instanceof FileTreeNode) {
return ((FileTreeNode)o).file.getAbsolutePath();
return null;
// Returns the File for a path, or null if not a known path
public File getFile(TreePath path) {
Object o = path.getLastPathComponent();
if (o instanceof FileTreeNode) {
return ((FileTreeNode)o).file;
return null;
// Inner class that represents a node in this file system tree
protected static class FileTreeNode extends DefaultMutableTreeNode {
public FileTreeNode(File parent, String name)
throws SecurityException, FileNotFoundException {
this.name = name;
// See if this node exists and whether it is a directory
file = new File(parent, name);
if (!file.exists()) {
throw new FileNotFoundException("File " + name + " does not exist");
isDir = file.isDirectory();
// Hold the File as the user object.
setUserObject(file);
// Override isLeaf to check whether this is a directory
public boolean isLeaf() {
return !isDir;
// Override getAllowsChildren to check whether this is a directory
public boolean getAllowsChildren() {
return !isDir;
// For display purposes, we return our own name
public String toString() {
return name;
// If we are a directory, scan our contents and populate
// with children. In addition, populate those children
// if the "descend" flag is true. We only descend once,
// to avoid recursing the whole subtree.
// Returns true if some nodes were added
boolean populateDirectories(boolean descend) {
boolean addedNodes = false;
// Do this only once
if (populated == false) {
if (interim == true) {
// We have had a quick look here before:
// remove the dummy node that we added last time
removeAllChildren();
interim = false;
String[] names = file.list(); // Get list of contents
// Process the directories
for (int i = 0; i < names.length; i++) {
String name = names;
File d = new File(file, name);
try {
FileTreeNode node = new FileTreeNode(file, name);
if (d.isDirectory()) {
//FileTreeNode node = new FileTreeNode(file, name);
this.add(node);
if (descend) {
node.populateDirectories(false);
addedNodes = true;
if (descend == false) {
// Only add one node if not descending
break;
else{   
//FileTreeNode node = new FileTreeNode(file,name);
this.add((MutableTreeNode)node);
//model.reload();
//model.nodeStructureChanged(node);
//((DefaultTreeModel)parent.getModel()).nodeStructureChanged(node);
} catch (Throwable t) {
// Ignore phantoms or access problems
// If we were scanning to get all subdirectories,
// or if we found no subdirectories, there is no
// reason to look at this directory again, so
// set populated to true. Otherwise, we set interim
// so that we look again in the future if we need to
if (descend == true || addedNodes == false) {
populated = true;
} else {
// Just set interim state
interim = true;
return addedNodes;
protected File file; // File object for this node
protected String name; // Name of this node
protected boolean populated;// true if we have been populated
protected boolean interim; // true if we are in interim state
protected boolean isDir; // true if this is a directory
// Inner class that handles Tree Expansion Events
protected class TreeExpansionHandler implements TreeExpansionListener {
public void treeExpanded(TreeExpansionEvent evt) {
TreePath path = evt.getPath(); // The expanded path
JTree tree = (JTree)evt.getSource(); // The tree
// Get the last component of the path and
// arrange to have it fully populated.
FileTreeNode node = (FileTreeNode)path.getLastPathComponent();
if (node.populateDirectories(true)) {
((DefaultTreeModel)tree.getModel()).nodeStructureChanged(node);
public void treeCollapsed(TreeExpansionEvent evt) {
// Nothing to do

There is a method for reloading a tree
Have a look at this:
http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/tree/DefaultTreeModel.html#reload(javax.swing.tree.TreeNode)
Hope I understood your problem and it helps.

Similar Messages

  • Streaming audio from my IPAD to my Apple TV from Rhapsody application.  when Apple TV go into Screen Saver mode, about 5 minutes after that it stops playing the Audio Stream and goes into Sleep mode.

    I am Streaming audio from my IPAD to my Apple TV from Rhapsody application.  when Apple TV go into Screen Saver mode, about 5 minutes after that it stops playing the Audio Stream and goes into Sleep mode.  I am using the Optical Out from the Apple TV to my receiver, the Apple TV is hard Wired to the Network, the IPAD is Wirelessly attached to the network (it continues to play the Audio Stream).  When the Apple TV is turned back on it resumes playing once I manual select it for output from the IPAD.  All device are on current releases of software.  I have no Video hooked up to the Apple TV.  How do I correct this?

    Intermittent problems are often a result of interference. Interference can be caused by other networks in the neighbourhood or from household electrical items.
    You can download and install iStumbler (NetStumbler for windows users) to help you see which channels are used by neighbouring networks so that you can avoid them, but iStumbler will not see household items.
    Refer to your router manual for instructions on changing your wifi channel or adjusting your multicast rate.
    There are other types of problems that can affect networks, but this is by far the most common, hence worth mentioning first. Networks that have inherent issues can be seen to work differently with different versions of the same software. You might also try moving the Apple TV away from other electrical equipment.

  • My 5 year old MacBook Air is telling me it "cannot save information about your mailboxes because there isn't enough space in your home folder.  Quit mail, delete files you don't need, then reopen mail."  What is "home folder," and which files to delete?

    My 5 year old MacBook Air is telling me it "cannot save information about your mailboxes because there isn't enough space in your home folder.  Quit mail, delete files you don't need, then reopen mail."  What is "home folder," and which files to delete? Thanks.

    The home folder is where all of your personal files are kept.
    Best candidates to delete are movies, videos, music and photos since they generally take the most space.
    Don't forget to empry the Trash after you delete the file because the space is not returned until the Trash is emptied.
    Allan

  • JTree refresh without collapsing my nodes

    Hello,
    I have a JTree using a custom TreeModel. I've also extended the TreeNode.
    What is the most elegant method to refresh the tree or only a node without
    collapsing the currently expanded nodes?
    Please note that there are multiple types of TreeNodes each representing
    a different object to display in the tree and contains an object that represents its
    value. Also the node has a method createChildren() to determine and create
    the child TreeNodes. Children are loaded from a business delegate. I need the
    tree to re-query the model (maybe for only one node) about the data and redisplay
    the changes without affecting the collapsed/expanded state of the nodes that
    are not changed (not supposed to refresh).
    My model actually asks the node for data like getChildsCount(), isLeaf() etc, etc.
    I'd like to say:
    myCustomNodeInstance.refresh();
    or
    myCustomTreeModelInstance.refresh(myCustomNodeInstance);
    and all nodes that are not children of myCustomNodeInstance to preserve
    their state.
    Thanx

    Did you try to call repaint() method on JTree ?

  • Save and load jtree

    Hi,
    I have a jtree which I would like to save and then load and display in a JPanel. Just for info, the nodes of the tree are instances of a user object i have created. Now I have looked into two ways of doing this:
    1) Serialize the actual JTree object; write it to a file using objectoutputstream and then read it in using objectinputstream, OR
    2) Serialize the tree model again using objectoutputstream then read the model back and create a new JTree initialising with the model i read in.
    I made some progress using the second approach, but when I load the tree model back and create a new tree with that model it just displays as a blank root with blank children. (Although the tree structure is the same).
    What am i doing wrong?
    The code is:
    public void saveTheTree() {
            TreeModel tm = tree1.getModel();
            try {
                 ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("treeModel"));
                 out.writeObject(tm);//the actual tree object
                 out.flush();
                 out.close();
            catch(IOException e){}
      public void openTheTree() {
           ObjectInputStream in = null;
             try {
                 in = new ObjectInputStream(new FileInputStream("treeModel"));
                 TreeModel atm = (TreeModel) in.readObject();
                 JTree loaded = new JTree(atm);
                 abPanel3.removeAll();
                 abPanel3.revalidate();
                 abPanel3.add(loaded, BorderLayout.CENTER);
                 abPanel3.revalidate();
             catch(Exception e) {
                  e.printStackTrace();
      }abPanel3 is where the tree is displayed and tree1 is my tree.
    Any help would be much appreciated!

    well the leaves are defaultmutabletreenodes instantiated with a user object which attaches a link and level to each one. According to the java documentation, defaultmutabletreenode is serializable, but do i need to serialize each node of the tree as well?
    Has anyone managed to save and load a jtree before?
    Thanks.

  • Quick Q about Jtree

    Hey, here is the scenario...a Jtree is in JScrollPane.. i can set tree background by calling myTree.setBackground(), and I can set the text color of tree node by creating my own JTreeCellRenderer to override the getTreeCellRender() .. but there is always a shadow around the tree bnode. I tried JComponent)mytree.getTreeCellRender().setOpaque(false) , then set treeCellRender.background..but it doesnot work.. any insight?

    sorry about my Typo. Tree bnode = Tree Node. Every node (including root ) has an urgly shadow!!

  • Some problems about jtree, undo

    I wrote a programme about do somethings to this jtree, like add a node, remove a subtree, but I wanna add a function of undo, but I don't know how. Like I operated this jtree, but I wanna undo, how?
    give some advice, thanks

    Look at this to get started:
    http://www.java2s.com/Code/Java/Swing-JFC/UndoExample4.htm

  • JTree refresh probleme help me please

    a can't reload my JTree from my server
    my Jtree code:
              user.add("Zeus@mxf");
              user.add("Neptune@toto");
              user.add("Ulysse@mars");
         root =new DefaultMutableTreeNode("users");
              for(int i=1; i<user.size(); i++)
              userNode = new DefaultMutableTreeNode
    (user.elementAt(i) );
                   root.add(userNode);     
              renderer.setOpenIcon(OpenIcon);
         renderer.setClosedIcon(ClosedIcon);
         renderer.setLeafIcon(PrinterIcon);
              tree=new JTree(root);
              tree.setCellRenderer(renderer);
    and if a have receive the write data i do my refresh methode:
    refresh()
    userNode = new DefaultMutableTreeNode(user.elementAt(0) );
                                  root.add(userNode);     
                                  ((DefaultTreeModel)tree.getModel()).reload();
                                  tree.treeDidChange();
                                  tree.setCellRenderer(renderer);
                                  tree.setLargeModel(true);     
                                  tree.repaint();
                                  tree.revalidate();
    why it dose not work ?????

    Sorry I have not ready examples, try to implement a method this way:
    String newUser = user.elementAt(0);
    public void addNode(String newUser){
    DefaultMutableTreeNode userNode = new DefaultMutableTreeNode(newUser);
    root.add(userNode);
    tree.getModel().nodeChanged((TreeNode)tree.getModel().getRoot());
    tree.treeDidChange();

  • Save information about travel plan

    Hi!
    I´m looking for the cluster or table where system save the information about travel plan, someone kows it??.
    On the other hand, I wold like to know if it´s possible to control the following case:
    One employee have booked a plain but in serch result there were plain cheaper than plain selected, we save this information (if there were plain cheaper than selected) in any place??.
    Thanks.

    Hi,
    travel plan is saved in a bunch of tables, especially FTPT_REQEST, FTPT_REQ_HEAD, FTPT_PLAN. In addition an entry in cluster PCL1 is created. Also have a look at the other tables
    starting with FTPT_ , like FTPT_ITEM.
    Regards,
    Arinze

  • The Great JTree Refreshing Problem!

    hi, i am using a Jtree to display information retrieved from an X.500 directory.
    I am dealing with a great amount of information, and performance is the great issue in here. So, my problem is that, retrieving 3000 entries from the directory with JNDI takes 1 second,building and inserting the 3000 nodes takes 3 seconds, and in the end, the refresh of the jtree takes 7 seconds!!!!!
    It's just to mutch time... i've tried dividing the 3000 entries in sets of 100 and insert this sets one at the time, so the JTree could refresh itself, this way, the user would see some action hapenning and it would be a lot more happy than he is now... The problem is that, the Jtree do not makes this refresh, only when a insert all, she starts to refresh and takes the infamous 7 seconds.
    does this have anything to do with the low priority of the Swing threads that makes the refreshment...
    please... any help is welcome
    thanks in advance

    use DefaultMutableTreeNode's insert/add methods to add
    the node.
    Steps:
    - make the root node.
    - insert the nodes in the root node,
    - set the root node as the root to the treemodel.
    it may be useful to u.A little off the subject of the original question, but when I want to use the same JTree to display new information (instead of popping up a new frame with the new info), I also create a new root node, populate it, and then set the currently-displayed JTree's model's root to the new root node. However it never redraws with the new tree contents, even though I call invalidate() on the JTree.
    What explicitly do you do to have it redraw with the new contents?
    Thanks!
    Lloyd

  • JTree refresh problem

    I use a JTree for displaying a custom TreeModel based on a DOM document. I have a problem with refreshing the tree: the tree refreshes itself correctly when it has focus, and does nothing when it has not (at least it seems to be related to focus), even though TreeModelEvents are fired. I know the problem originates from the custom TreeModel (others work fine), but I can't find what's wrong. I compared it to the DefaultTreeModel source and found nothing interesting.
    In addition to that, the tree is displayed without its vertical connecting lines (but someone told me its a symptom of bad refreshing).
    Anyone has an idea? Thanks in advance.
    Simon

    I faced the same problem. Try adding a TreeModelListener and updateUI in it . . .
    yourTreeModel.addTreeModelListener(new TreeModelListener() {
    public void treeNodesChanged(TreeModelEvent e) {}
    public void treeNodesInserted(TreeModelEvent e) {
    yourTree.updateUI();
    public void treeNodesRemoved(TreeModelEvent e) {
    yourTree.updateUI();
    public void treeStructureChanged(TreeModelEvent e) {}
    });

  • JTree refresh

    Hi!!!
    I'm trying to implement JTree with TreeModel that sores the data in Document (as a result of XML parsing). I want to be able to refresh the tree when the data is changed.
    I read in some tutorials that to do it I shoul implement in TreeModel functions like fireTreeNodeInserted(Node parent, Node child), fireTreeNodeChanged , etc.
    But I can't understand what the implementation of those functions should be like?
    Please ,help me :)
    Yana.

    In addition to es5f2000's advice (which is good), I also suggest you take a look at the API for the TreeModelListener interface:
    http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/event/TreeModelListener.html
    It describes what kind of events your TreeModel should fire, and when it should do it.

  • About JTree Edit

    Hi all,
    I need implement the funtion:when user select one node and right click,if click 'rename' item in popup-menu,the node selected will enter editing status,and user type some characters then input 'enter' key or click somewhere other than the node,edit is complete,and application get the new value and save to database.
    I has some question when coding:
    1.I find http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html#dynamic not work,when edit the node(select and F2) then type some characters and complete,noting happened.how?
    2.how can I catch the event representing edit has completed,so I can save the new name to database?
    Thanks!

    Actually - to simplify the question, I have the following:
    JTree --> UserTreeModel --> UserData
    This is similar to the Genealogy example. So, given a UserData item, how do I find the TreePath for that item in the JTree and start an edit on that Path in the tree programatically?
    Edited by: QetuP on Mar 1, 2008 8:42 AM

  • Quetions about jtree

    1,how can know there are how many subnodes of a node in jtree?
    2,jtree structure likes this :
    line 1, rootnode
    line 2, ------node1
    line 3, ------node2
    line 4, --------node2node1
    line 5, ------node3
    question is : if I wanna know the nodeN at line N, How can I get the nodeN quickly?
    3,how can I change the nodename ?
    4,how can I save the changes to xml?

    Hi,
    First read this tutorial :
    http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html
    Important classes for you are in the the package :
    javax.swing.tree.;*
    look at those classes.
    For your question the class
    DefaultMutableTreeNode could be usefull.
    There you can get the number of childrens of a node , the path to the root or to other nodes in the tree.
    To store the changes into a xml file you can easily save the tree as a xml file with a xml writer
    javax.beans.XMLEncoder;
    public boolean serializeObjectToXML(Object[] o, String filename) {
        boolean success = false;
        try {
          XMLEncoder xmle = new XMLEncoder(new FileOutputStream(filename));
          for (int i = 0; i < o.length; i++) {
            xmle.writeObject(o);
    xmle.close();
    success = true;
    catch (IOException ioe) {
    ioe.printStackTrace();
    success = false;
    return success;
    think this is a start.
    Olek

  • Help with JTree refresh

    I am having trouble displaying a JTree with newly added nodes.
    I have a JTree, inside a JPanel, JScrollPane and JSplitPane.
    I create the JTree with a single root node which displays correctly.
    I update the JTree with new children which displays correctly.
    Using the same exact routine as above - I add additional new children to the root, the new children do not display in the JTree.
    I have confirmed that I am using the correct tree and root node in debug that the tree/node objects has been correctly updated. It is just not displaying the new children to the root.
    I can expand and collapse the tree which does not show the new children, just the original populated root.
    After the root has been updated, I have tried a number of methods to resolve: tree/jpanel/jscrollpane/jsplitpane .revalidate, invalidate, repaint, etc.
    I am using v1.4.1.
    What am I missing here?
    Thanks in advance.

    i use two classes fro add or insert nodes in a tree, one adds the node at the same level of the current selected node, and the other intert it inside:
    // InsertaTreeConfAction.java
    package ayto;
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    import java.io.*;
    import javax.swing.tree.*;
    public class InsertaTreeConfAction extends AbstractAction {
    TreeConf treeConf;
    MenuTreeConf menuPrincipal;
    TreeConfAppAyto confNodo;
    DefaultTreeModel model;
    TreeTreeConf tree;
    public InsertaTreeConfAction(TreeConf treeConf,String text) {
    super(text);
    this.treeConf = treeConf;
         InitAction();
    public InsertaTreeConfAction(TreeConf treeConf, String text, Icon icon) {
    super(text, icon);
    this.treeConf = treeConf;
         InitAction();
    public void InitAction(){
         menuPrincipal = treeConf.getMenu();
         confNodo = treeConf.selNodo;
         model = treeConf.getTree().getMyModel();
         tree = treeConf.getTree();
    public void actionPerformed(ActionEvent ev) {
              model = treeConf.getTree().getMyModel();
              TreePath tp = tree.getSelectionPath( );
         MutableTreeNode insertNode = (MutableTreeNode)tp.getLastPathComponent( );
         int insertIndex = 0;
              if (insertNode.getParent( ) != null) {
              MutableTreeNode parent = (MutableTreeNode)insertNode.getParent( );
              //insertIndex = parent.getIndex(insertNode) + 1;
              //insertNode = parent;
         MutableTreeNode node = new DefaultMutableTreeNode(new TreeConfAppAyto("Nodo Insertado"));
         model.insertNodeInto(node, insertNode, insertIndex);
    treeConf.estadoConfApp = TreeConf.NODO_MODIFICADO;
    treeConf.updater.update(); // esto no colapsa el arbol
    treeConf.setTitle("AYTO de Huelva - Configuraci�n de men�s: "+treeConf.fileAct);
    // AnadeTreeConfAction.java
    package ayto;
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    import java.io.*;
    import javax.swing.tree.*;
    public class AnadeTreeConfAction extends AbstractAction {
    TreeConf treeConf;
    MenuTreeConf menuPrincipal;
    TreeConfAppAyto confNodo;
    DefaultTreeModel model;
    TreeTreeConf tree;
    public AnadeTreeConfAction(TreeConf treeConf,String text) {
    super(text);
    this.treeConf = treeConf;
         InitAction();
    public AnadeTreeConfAction(TreeConf treeConf, String text, Icon icon) {
    super(text, icon);
    this.treeConf = treeConf;
         InitAction();
    public void InitAction(){
         menuPrincipal = treeConf.getMenu();
         confNodo = treeConf.selNodo;
         model = treeConf.getTree().getMyModel();
         tree = treeConf.getTree();
    public void actionPerformed(ActionEvent ev) {
              model = treeConf.getTree().getMyModel();
              TreePath tp = tree.getSelectionPath( );
         MutableTreeNode insertNode = (MutableTreeNode)tp.getLastPathComponent( );
         int insertIndex = 0;
              if (insertNode.getParent( ) != null) {
              MutableTreeNode parent = (MutableTreeNode)insertNode.getParent( );
              insertIndex = parent.getIndex(insertNode) + 1;
              insertNode = parent;
         MutableTreeNode node = new DefaultMutableTreeNode(new TreeConfAppAyto("Nodo A�adido"));
         model.insertNodeInto(node, insertNode, insertIndex);
    treeConf.estadoConfApp = TreeConf.NODO_MODIFICADO;
    treeConf.updater.update(); // esto no colapsa el arbol
    treeConf.setTitle("AYTO de Huelva - Configuraci�n de men�s: "+treeConf.fileAct);

Maybe you are looking for

  • Function module to send mail from SAP

    Can any one please tell the Function module to send mail from SAP. The scenario is like this,I have a file in local system that i have to send to a particular mail address like [email protected] through a report program.

  • 60i to 24p

    Can anyone walk me through the steps of converting 60i SD footage to 24p footage that can be played back on a 60i timeline in Final Cut? I realize that anything playing on a 60i timeline is going to be interlaced but I want the same 24p look that the

  • Trying to add OnCick to Spry Tab

    I have a page that has 4 Spry tabbed panels...within each panel are sets of sliding panels.  All works perfectly. However, if I navigate to tab 1, sliding panel 3, then click on tab 2, and then back to tab 1, the sliding panel in tab 1 has remained a

  • 2nd monitor says in input - what to do?

    Hello. I have been having trouble getting a 2nd monitor to connect with my computer on the windows side. Two days ago the monitor just quit working and says no input when I turn it on. I have checked drivers for HP, nvidia, and updated my apple softw

  • Mac Photoshop CS6 crash with NVIDIA GTX470 graphics card

    Hi there, I don't know whether this is an Adobe bug or NVIDIA driver problem. I've recently upgraded my Mac Pro's graphics card from an Asus 256MB 8400GS to a 1GB NVIDIA GeForce GTX 470. Everything seems to work fine in CS6 suite apart from a weird a