Results 1 to 3 of 3
  1. #1
    PrinceSendai is offline Member
    Join Date
    Jul 2010
    Location
    Lima, Peru
    Posts
    47
    Rep Power
    0

    Post nodeChanged() not firing/working?

    Whenever I edit the textbox it should modify the user object of the current node in my JTree, and reflect in the tree.

    I use nodeChanged() to update the JTree. However, the change still is not showing.

    I have simplified my code a little bit. If you know why it is not reflecting the change and refreshing the tree, please let me know.

    Java Code:
    final theTextBox = textBox;
    textBox.getDocument().addDocumentListener(new DocumentListener(){
    			public void insertUpdate(DocumentEvent e){
    
    
    				
    
    				DefaultMutableTreeNode node = (DefaultMutableTreeNode) myjtree.getLastSelectedPathComponent();
    
    
    				String str = (String) node.getUserObject();
    
                                    str = str + theTextBox.getText();
    
                                    model.nodeChanged(node);
    
    			}
    });

    EDIT:

    Now it is showing an ellipsis (the highlighting is not resizing). The only change I did was to make sure the text of the textbox and the userObject of the node are equal, BEFORE editing the textbox.

    It is still showing the ellipsis issue despite the fact that nodeChanged() is supposed to fix this issue.
    Last edited by PrinceSendai; 03-23-2011 at 08:46 PM.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,193
    Rep Power
    19

    Default

    To get better help sooner, post a SSCCE (Short, Self Contained, Compilable and Executable) example that demonstrates the problem.

    db

  3. #3
    lovelesh is offline Senior Member
    Join Date
    Nov 2010
    Location
    Delhi
    Posts
    135
    Blog Entries
    1
    Rep Power
    0

    Smile

    Quote Originally Posted by PrinceSendai View Post

    String str = (String) node.getUserObject();

    str = str + theTextBox.getText();
    Add this line after above code:

    node.setUserObject(str);

Similar Threads

  1. setText is not firing...! Why?
    By N00Bie in forum New To Java
    Replies: 14
    Last Post: 02-20-2011, 09:59 PM
  2. Why isn't this working?
    By nickburris in forum New To Java
    Replies: 14
    Last Post: 02-03-2011, 02:00 AM
  3. Replies: 2
    Last Post: 01-04-2011, 04:30 AM
  4. Replies: 8
    Last Post: 05-28-2008, 07:00 AM
  5. Working With ANT
    By JavaForums in forum Eclipse
    Replies: 0
    Last Post: 04-26-2007, 08:16 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •