Help with JTree Update

Hi there,
I need to do a simple thing with a JTree but I 've got a problem. Well I want to create a very very very simple bookmark function. I have a tree with the children and I want to add new children which are going to work like link for my program. I try to add new children the same way I created them but it's not working. I tried also the updateUI method that somebody mentioned in an other topic but still nothing. Can somebody help?
Here is the Bookmark Panel code:
import javax.swing.*;
import javax.swing.tree.*;
import javax.swing.event.*;
import java.awt.*;
public class BookmarkTry implements TreeSelectionListener {
    private JScrollPane scrollPane;
    private JLabel label;
    DefaultMutableTreeNode root = new DefaultMutableTreeNode("Bookmarks");
    private JTree tree;
    private JPanel panel = new JPanel();
     public BookmarkTry(){
     public JPanel createpanel(){
     tree = new JTree(root);
     root.add(new DefaultMutableTreeNode(new Bookmark("Chapter 1","about.html")));
    root.add(new DefaultMutableTreeNode(new Bookmark("Chapter 2","aaa.html")));
    root.add(new DefaultMutableTreeNode(new Bookmark("Chapter 3","sdss.html")));
    // build tree
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.addTreeSelectionListener(this);// get selection events!
    // build form
    scrollPane = new JScrollPane(tree);
    label = new JLabel(" ");
    //scrollPane.setViewportView(tree);
    panel.add(label);
    panel.add(scrollPane);
    return panel;
    public void addBookMarks(String name, String page){
         root.add(new DefaultMutableTreeNode(new Bookmark(name,page)));
         //DefaultTreeModel.reload();
    public void valueChanged(TreeSelectionEvent treeSelectionEvent) {
        DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode)tree.getLastSelectedPathComponent();
        if ((selectedNode!=null)&&(selectedNode.isLeaf())) {
            Bookmark b = (Bookmark)selectedNode.getUserObject();
            label.setText("Go to page "+b.getPage());
    private static class Bookmark {
        private String caption;
        private String page;
        public String getPage() {
            return page;
        public Bookmark(String caption, String page) {
            this.caption = caption;
            this.page = page;
        public String toString() {
            return caption;
     and here how I try to add the node :
void jButton1_actionPerformed(ActionEvent e) throws java.sql.SQLException {
        DefaultMutableTreeNode book = null;
        System.out.println("You pressed the add button of bookmarkframe");
        //Bookmark.getTreePanel().addObject(name.getText());
        //book = new DefaultMutableTreeNode(new BookInfo(name.getText(),page.getText()));
        System.out.println(name.getText());
        System.out.println(page.getText());
        tempb.addBookMarks(name.getText(),page.getText());
        frame.dispose();
   } //void jButton1_actionPerformedIt doesn't add the new node in my JTree
Thanks in advance

I still suspect you have two (or more) new BookmarkTry() executions somewhere. But I can't see all of your code here of course. My standard reply, so we don't waste time guessing:
1) In the future, Swing related questions should be posted in the Swing forum.
2) If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program (SSCCE) that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
And don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags so the code retains its original formatting.
Note, we don't want your whole application. We want an SSCCE!

Similar Messages

  • Can anyone help with problem updating iphone5s cant get anything only apple on screen sometimes screen flashes blue

    can anyone help with problem updating iphone5s cant get anything only apple on screen sometimes screen flashes blue

    Hey damien555,
    Thanks for the question, I understand how frustrating this may be. It sounds like the update process may have been interrupted, and to resolve the issue, we’ll need to restore your device in recovery mode with iTunes:
    If you can't update or restore your iOS device
    http://support.apple.com/kb/HT1808
    Thanks,
    Matt M.

  • Help with this update statement..

    Hi everyone,
    I am trying to update a column in a table .I need to update that column
    with a function that takes patient_nbr and type_x column values as a parameter.
    That table has almost "300,000" records. It is taking long time to complete
    almost 60 min to 90 min.
    Is it usual to take that much time to update that many records?
    I dont know why it is taking this much time.Please help with this update statement.
    select get_partner_id(SUBSTR(patient_nbr,1,9),type_x) partner_id from test_load;
    (it is just taking 20 - 30 sec)
    I am sure that it is not the problem with my function.
    I tried the following update and merge statements .Please correct me if i am wrong
    in the syntax and give me some suggestions how can i make the update statement fast.
    update test_load set partner_id = get_partner_id(SUBSTR(patient_nbr,1,9),type_x);
    merge into test_load a
    using (select patient_nbr,type_x from test_load) b
    on (a.patient_nbr = b.patient_nbr)
    when matched
    then
    update
    set a.partner_id = get_partner_id(SUBSTR(b.patient_nbr,1,9),b.type_x);
    there is a index on patient_nbr column
    and the statistics are gathered on this table.

    Hi Justin,
    As requested here are the explain plans for my update statements.Please correct if i am doing anything wrong.
    update test_load set partner_id = get_partner_id(SUBSTR(patient_nbr,1,9),type_x);
    "PLAN_TABLE_OUTPUT"
    "Plan hash value: 3793814442"
    "| Id  | Operation          | Name             | Rows  | Bytes | Cost (%CPU)| Time     |"
    "|   0 | UPDATE STATEMENT   |                  |   274K|  4552K|  1488   (1)| 00:00:18 |"
    "|   1 |  UPDATE            |        TEST_LOAD |       |       |            |          |"
    "|   2 |   TABLE ACCESS FULL|        TEST_LOAD |   274K|  4552K|  1488   (1)| 00:00:18 |"
    merge into test_load a
    using (select patient_nbr,type_x from test_load) b
    on (a.patient_nbr = b.patient_nbr)
    when matched
    then
    update
    set a.partner_id = get_partner_id(SUBSTR(b.patient_nbr,1,9),b.type_x);
    "PLAN_TABLE_OUTPUT"
    "Plan hash value: 1188928691"
    "| Id  | Operation            | Name             | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |"
    "|   0 | MERGE STATEMENT      |                  |   274K|  3213K|       |  6660   (1)| 00:01:20 |"
    "|   1 |  MERGE               |        TEST_LOAD |       |       |       |            |          |"
    "|   2 |   VIEW               |                  |       |       |       |            |          |"
    "|*  3 |    HASH JOIN         |                  |   274K|    43M|  7232K|  6660   (1)| 00:01:20 |"
    "|   4 |     TABLE ACCESS FULL|        TEST_LOAD |   274K|  4017K|       |  1482   (1)| 00:00:18 |"
    "|   5 |     TABLE ACCESS FULL|        TEST_LOAD |   274K|    40M|       |  1496   (2)| 00:00:18 |"
    "Predicate Information (identified by operation id):"
    "   3 - access("A"."patient_nbr"="patient_nbr")"Please give some suggestions..
    what's the best approach for doing the updates for huge tables?
    Thanks

  • Help with replicating/updating vendor master data

    Hi,
    Currently, we run the bbp_vendor_sync program to do the replication. It does the job of both bbpgetvd (new vendor creation) and bbpupdvd (update existing vendor).
    But the problem is, we have two number ranges for vendors. One is Numeric and other one is Alpha.
    Group -->AB     From 0010000000     to 0699999999
    Group -->AZ     From A     to ZZZZZZZZZZ
    The vendor synchronization program can consider only one number range at a time i.e.
    either Numeric or Alpha. So, we have to switch the active number range
    and run the program twice., first for numeric and then for alpha.
    In order to avoid this, I'm looking at implementing bbp_transdata_prep which I was told would take care of this issue.
    I looked around for documentation/sample code for bbp_transdata badi and couldnt find any on SAP help site or SDN.
    Wondering if someone can help with the documentation/sample code and difficuly level of implementing this BADI.
    Any help would be highly appreciated and suitable points would be awarded for your help.
    Also, if there is another way to solve this issue without implementing transdata badi, pls. let me know.
    TIA,
    Seyed

    Hi
    <u>Please go through this -></u>
    http://help.sap.com/saphelp_srm50/helpdata/en/56/54f137a5e6740ae10000009b38f8cf/frameset.htm
    http://help.sap.com/saphelp_srm50/helpdata/en/62/fb7d3cb7f58910e10000000a114084/frameset.htm
    http://help.sap.com/saphelp_srm50/helpdata/en/42/d3b671ba67136fe10000000a1553f7/frameset.htm
    http://help.sap.com/saphelp_srm50/helpdata/en/bb/6c0e3b02616a42e10000000a11402f/frameset.htm
    <b><u>Sample BADI Implementation
    BADI Definition - BBP_TRANSDATA_PREP
    Purpose -> Impl. for BBP_TRANSDATA_PREP, Delete Invalid Mail Addresses</u></b>
    <u>PREPARE_REPLICATION_DATA method -></u>
    method IF_EX_BBP_TRANSDATA_PREP~PREPARE_REPLICATION_DATA.
      FIELD-SYMBOLS: <LFS_ADR6> TYPE ADR6.
      LOOP AT CT_ADR6 ASSIGNING <LFS_ADR6>.
        IF <LFS_ADR6>-SMTP_ADDR NS '@'.
          DELETE CT_ADR6.
        ENDIF.
      ENDLOOP.
    endmethod.
    <u>PREPARE_UPDATE_DATA method -></u>
    method IF_EX_BBP_TRANSDATA_PREP~PREPARE_UPDATE_DATA.
      FIELD-SYMBOLS: <LFS_ADR6> TYPE ADR6.
      LOOP AT CT_ADR6 ASSIGNING <LFS_ADR6>.
        IF <LFS_ADR6>-SMTP_ADDR NS '@'.
          DELETE CT_ADR6.
        ENDIF.
      ENDLOOP.
    endmethod.
    Hope this will help.
    Regards
    - Atul

  • Help with CS5 Updates Failed, Updates could not be applied, Error Code U43M1D207

    CS5 Updates Failed, Updates could not be applied, Error Code U43M1D207
    Can anyone help with this error code?
    Products installed and activated on new laptop
    Unable to update using Adobe Application Manager
    Thank you

    I followed up on the Photoshop Error code and found some suggestions by Jeff Tranberry and Pete Green here.
    Michael

  • Help with a update,select statement

    Hi all please can you help me with a update statement i am struggling with.
    I have 2 tables
    Holiday and data
    In the Holiday table i have columns for
    Machine_ID NUMBER,
    date_from DATE,
    date_to DATE,
    ID NUMBER
    Machine column represents a type of machine, the two dates represent the start and end date of a holiday and ID represents the ID of the machines that the holiday effects (as you can have many machines that are the same, so the ID unique field to seperate them.
    i.e.
    996     25-DEC-08 00:00:00     27-DEC-08 00:00:00     91     
    996     25-DEC-08 00:00:00     27-DEC-08 00:00:00     92     
    100     28-DEC-08 00:00:00     29-DEC-08 00:00:00     1
    100     28-DEC-08 00:00:00     29-DEC-08 00:00:00     2
    In the data table i have the following columns:
    DATE DATE
    Machine NUMBER
    SHIFT1S DATE
    SHIFT1F DATE
    SHIFT2S DATE
    SHIFT2F DATE
    CALS DATE
    CALF DATE
    CAP NUMBER
    CALCAP NUMBER
    total_hrs_up NUMBER
    In here i have data for every date in the calendar. The machines are cross references with the machine in holidays table.
    I run two shifts so have shift 1 start, finish. shift 2 start, finish. These are dates with times, so shift1s could be 01-01-08 09:00:00 shift1f could be 01-01-08 17:00:00.
    shift2S could be 01-01-08 21:00:00 shift2f could be 01-01-08 23:59:00.
    so that machine would be up between them hours of the day.
    Other columns include
    CALS, ,CALF = calendar start, finish, - This needs to be populated from the holiday table. currently null. So if the date is the 26 DEC and the machine is the same as what is in the holiday table then these two columns should be populated with them data
    CAP is the total number of these machines i have available.
    CALCAP is the no of machines the holiday affects -currently null
    total_hrs_up is the number of hours this machine is up and running -currently null.
    So what i need to do is populate the cals, calf calcap, total_hrs_up columns.
    total_hrs_up is the important one, this needs to work out based on the two shift patterns the number of hours that the machine is available and then take off the holiday hours to give a final value.
    so current data example in data is
    date machine shifts shiftf shift2s shift2f cals, calf, cap, calcap, total_hrs
    16-JUL-08     100 09:00:00     17:00:00     12:00:00     00:00:00               '','','',1     ,''     
    16-JUL-08     105 09:00:00     17:00:00     12:00:00     00:00:00               '','','',1     ,''
    16-JUL-08     107 09:00:00     17:00:00     12:00:00     00:00:00               '','','',1     ,''
    id like to see based on the holiday table if there is a holiday then this data is updated as such and a total_hrs machine is available populated on that date.
    Any help is very much appreciated!
    Thanks

    Hi,
    The following query does what you requested.
    It makes the following assumptions:
    (a) in data, shift1start <= shift1finish
    (b) in holiday, hol_start <= hol_finish
    (b) in data, the combination (machine, shift1start) is unique
    (c) in holiday, hol_start <= hol_finish
    (d) in holiday, rows for the same machine and id never have overlapping dates (including times). For example:
    INSERT INTO holiday (machine, id, date_from, date_to)
    VALUES (200, 1, '26-DEC-08 07:00:00', '26-DEC-08 09:59:59');
    INSERT INTO holiday (machine, id, date_from, date_to)
    VALUES (200, 1, '26-DEC-08 09:00:00', '26-DEC-08 09:59:59');will cause a probem. Multiple rows for the same machine and day are okay, however, if the times do not overlap, like the following:
    INSERT INTO holiday (machine, id, date_from, date_to)
    VALUES (200, 1, '26-DEC-08 07:00:00', '26-DEC-08 08:59:59');
    INSERT INTO holiday (machine, id, date_from, date_to)
    VALUES (200, 1, '26-DEC-08 09:00:00', '26-DEC-08 09:59:59');Here's the UPDATE statement:
    UPDATE     data     m
    SET     (     hol_start
         ,     hol_finish
         ,     no_of_available_minutes
         ) =
    (     SELECT     MIN (date_from)
         ,     MAX (date_to)
         ,     (     MAX (shift1finish - shift1start)     -- Total from data
              -     ( NVL     ( SUM     ( LEAST (date_to, shift1finish)
                             - GREATEST (date_from, shift1start)
                        , 0
                        )                    -- Total from holiday
                   / MAX (total_no_of_machines)          -- Average
              ) * 24 * 60                         -- Convert days to minutes
         FROM          data     d
         LEFT OUTER JOIN     holiday     h     ON     h.machine     = d.machine
                             AND NOT     (     date_from     > shift1finish
                                  OR      date_to          < shift1start
         WHERE          d.machine     = m.machine
         AND          d.shift1start     = m.shift1start
    );The subquery has to use its own copy of data (that is, in needs d, not m), since the subquery has to return a non-NULL number of minutes when no rows in h match m.

  • Help with a update query from a subquery

    Hello All,
    I wanted to see if someone can help me with an update query.
    I need to grab a latitude & longitude from a the same user that is in two accounts. therefore i am trying to update lat/long in a users table for one account based off of the same user in another account. I am matching the users up by phone number and last name. I tried a subquery but am having difficulty.
    I was thinking of something like the following:
    update users
    set lat = getlat, long = getlong
    inner join (select lat as getlat, long as get long from users where account_id = '1')
    on phone = phone and last name = lastname
    where account_id = '2' and lat IS NULL and long IS NULL
    Am I going in the right direction???
    Thanks in advance for any assistance!!!!

    What difficulty are you having? Have you tried what you posted and get an error?
    Although someone may be able to give you sql advice here, I would try posting this over at Stack Overflow as its not really related to Coldfusion.

  • Help with iPad update issue

    Need help with update issue please

    Please see your duplicate thread below for answer already provided.
    https://discussions.apple.com/message/25940896#25940896

  • Need help with understanding updates, partitions, firmware etc.

    I went to update my QuickTime and in doing so was told to update my OS which included QT updates. Now I'm getting all kinds of messages about partitions, firmware etc. do not understand at all what's going on.

    THIS IS MY STEP BY STEP situation with my updates:
    I go to the Apple Icon and selected Software Update and it reads I have 2 items:
    MacBook EFI Firmware Update 1.2
    MacBook SMC Firmware Update 1.4
    I select Install and then it state Installs completed successfully.
    BUT THEN I recieve and new icon and this message below: 
    To update the SMC firmware on your MacBook:
    Your computer's power cord must be connected and plugged into a working power source, or your battery must be at least 25% charged.
    For more information see 'http://support.apple.com/kb/TS3499'.
    1. Quit all other open applications.
    2. Click Restart in the MacBook SMC Firmware Update window and wait for your computer to restart.
    The SMC firmware update starts automatically. A status bar indicates the progress of the update. During the update your computer fans will run at full speed, but will return to normal once the update completes.
    Important: Do not interrupt the update.
    Your computer restarts automatically when the update is completed and opens the MacBook SMC Firmware Update.
    3.  Click OK. The SMC firmware is now up-to-date.
    If these instructions appear on your screen again, the SMC firmware update was not successful. Repeat steps 2 and 3.
    I follow the instructions and then I get this: (could get my image to attach but here's what it said)
    the first error message heading of:
    MacBook SMC Firmware Update 1.4
    Your firmware could not be updated, the hard drive partition scheme may not be supported.  You must be booted from a GUID partition or RAID scheme.
    see http://support.apple.com/kb/HT2434 for more information (internal error 28:3)
    THEN ANOTHER ONE POPS UP saying:
    Your Hard Drive partition scheme is not supported, you must be booted from a GUID partition scheme.
    see http://docs.info.apple.com/article.html? artnum=303609 for more information
    I went to those URL and tried to understand what it was telling me but I did not understand.  I can't figure, by reading thru forums, etc, if I need to do this or not and what exactly it is.
    So back to just pushing a simplet update has thrown all this unknown info. my way and I have no clue what to do.
    Thank you. Hope this is more clear.

  • I need help with application updates

    My problem  is with applications updateing i changed my e-mail address but my old one still is listed  and i can't update  new applications how can i change that ID

    no iam refering to the application icon shows six updates and  i  touch it and it shows my old e-mail address which is [email protected]

  • Help with live updating and downgrade

    Since upgrading to the latest firmware I lost the ability for my smart playlists to be updated on the fly as before. I want to restore my original firmware if possible since I don't see anything new or better with the newest firmware. Is it possible, and if so how. I see the restore function for the firmware updater but I wasn't sure if that restores the firmware too or just removes files only. TIA

    you will need to restore and then update with the updater for the version you want.
    Rememeber that doing a restore will erase everything on your iPod

  • Help with iphone update to 7.0.4 - wont restore or leave the connect to itunes screen

    Hello,
    I am currently overseas in Thailand and decided to try to update my iso from 6 to 7. Initially I went through settings>software update with a strong connection to wifi - it downloaded on my phone but then instead of updating came with the screen connect to itunes (I am thinking because there wasnt enough space on my iphone?). I have now connected it to a computer with the most updated version of itunes.
    The screen on itunes looks like this:
    IPhone Recovery Mode
    Your iphone software is up to date, iTunes will automatically look for an update again on the 24/2/2014.
    The two buttons below say "check for update (grey)" and "restore iphone (can click)" - I have clicked restore iphone and it proceeded to download iphone software update (1.12GB) - once downloaded nothing changes, i cannot apply the download to my iphone and still my iphone has the connect to itunes screen - I have done this twice and nothing has changed.
    I would really appreciate any help or advice on what is happening, and why it cant restore my iphone -
    Apple tech geeks encouraged to respond!!! please!!! I really need to have my iphone working again.
    Thankyou in advance
    Elyssa
    At all stages I have tried holding the circle button and top button to reset iphone but nothing changes!

    Put the iPhone in DFU mode, (Google how to put iPhone in DFU mode).
    Shift+Restore if using PC, Option+Restore for Mac, point to already downloaded firmware. You may have to un-hide folders to see the .IPSW file

  • Help with N73 update

    Hello everybody.
    I have a problem updating my N73. My current software version is 2.0628.0.0.3 27-07-2006 - which I know is pretty old but when I
    try to update with my software updater it tells me that there are no update versions for my phone.
    Also when i search for updates on the Nokia site by entering my phone model code it says that there aren't any available updates.
    What can I do to finally update my phone? Is my software non-updateable? The model's code is 0539296.
    I would really appreciate some help on this. Thanks in advance!

    There is no update for your phone!
    You have to look at the number after Nokia N73 (xx.xx)
    It is standig here:
    V20628.0.0.1
    10-7-2006
    RM-133
    Nokia N73 and then the number.
    If you have Nokia N73 (xx) you can update to version 3
    If you have Nokia N73 (xx.xx) you have a Benelux version and you have to wait for another next update. Check it every month!

  • Help with iTunes update and accidentally syncing phone to another iTunes account

    I'm really hoping someone can help me.
    Earlier tonight I updated iTunes on my laptop. I synced my phone and backed it up only to find an hour later when I was going through my messages that all of my contacts were gone. I read up online and apparently this was a common problem with the new update. I've tried the suggestion of going into settings>icloud and turning my contacts on but my numbers are still gone. When I plugged my phone into my computer again to restore the backup, It automatically started to sync again. I clicked cancel straight away but the previous backup changed from earlier on in the evening to the current time. So now I've no backup from earlier, Just from after I realised my contacts were gone.
    I also noticed when I was clicking around that my partners email was signed into the itunes account, not my email. I signed him out and signed myself back in but nothing has returned.
    Does anybody have a solution for this? I know I can't use a previous backup because it updated the backup to after I noticed the contacts were gone. I also tried restoring my computer to an earlier time from before I backed up iTunes but there's no recent backups of my computer. I also tried signing into iCloud but theres no contacts there either.
    I have a feeling all of this was caused because my partners email was signed into iTunes when my phone backed up but I'm curious as to why it would just delete my contacts and nothing else?

    If you have an iPad 1, the max iOS is 5.1.1. For newer iPads, the current iOS is 6.0.1. For the iPad Mini the iOS is 6.0.2. The Settings>General>Software Update only appears if you have iOS 5.0 or higher currently installed.
    iOS 5: Updating your device to iOS 5 or Later
    http://support.apple.com/kb/HT4972
    How to install iOS 6
    http://www.macworld.com/article/2010061/hands-on-with-ios-6-installation.html
    iOS: How to update your iPhone, iPad, or iPod touch
    http://support.apple.com/kb/HT4623
    If you are currently running an iOS lower than 5.0, connect the iPad to the computer, open iTunes. Then select the iPad under the Devices heading on the left, click on the Summary tab and then click on Check for Update.
    Tip - If connected to your computer, you may need to disable your firewall and anitvirus software temporarily.  Then download and install the iOS update. Be sure and backup your iPad before the iOS update. After you update an iPad (except iPad 1) to iOS 6.x, the next update can be installed via wifi (i.e., not connected to your computer).
     Cheers, Tom

  • 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