473,320 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

TreeModel events problem

Hello,

I have a problem to catch tree events using a JTree associated with a
custom TreeModel. I would like an editable JTree, and when the user
updates some nodes of the tree, I would like the model also updated
and view the update. But in my case when the user updates a node, the
old value remains. What am I doing wrong?

Thanks

Here is my code:

public class XMLTreeModel implements TreeModel {

[... Other methods of TreeModel interface]

private Vector listenerList = new Vector();
public void addTreeModelListener(TreeModelListener listener) {
if(listener != null && !listenerList.contains(listener)) {
listenerList.addElement(listener);
}
}

public void removeTreeModelListener(TreeModelListener listener) {
if(listener != null) {
listenerList.removeElement(listener);
}
}
}

----

public class XMLTreeModelListener implements TreeModelListener {

public void treeNodesChanged(TreeModelEvent e) {
System.out.println("Wassup");
}

public void treeNodesInserted(TreeModelEvent e) {
System.out.println("Wassup1");
}

public void treeNodesRemoved(TreeModelEvent e) {
System.out.println("Wassup2");
}

public void treeStructureChanged(TreeModelEvent e) {
System.out.println("Wassup3");
}
}

---

JTree t = new JTree();
t.setEditable(true);
xmlTreeScrollPane = new JScrollPane(t);
....
XMLTreeModel xmlTreeModel = new XMLTreeModel(doc); // doc is an XML
Document
xmlTreeModel.addTreeModelListener(new XMLTreeModelListener());
t.setModel(xmlTreeModel);
Jul 17 '05 #1
2 2991
Sydney wrote:
Hello,

I have a problem to catch tree events using a JTree associated with a
custom TreeModel. I would like an editable JTree, and when the user
updates some nodes of the tree, I would like the model also updated
and view the update. But in my case when the user updates a node, the
old value remains. What am I doing wrong?


Does your custom TreeModel implement valueForPathChanged()?

HTH,
Ray

--
XML is the programmer's duct tape.
Jul 17 '05 #2
No, It's the only one I did not implement

Sydney

Raymond DeCampo <rd******@spam.twcny.spam.rr.spam.com.spam> wrote in message news:<tm******************@twister.nyroc.rr.com>.. .
Sydney wrote:
Hello,

I have a problem to catch tree events using a JTree associated with a
custom TreeModel. I would like an editable JTree, and when the user
updates some nodes of the tree, I would like the model also updated
and view the update. But in my case when the user updates a node, the
old value remains. What am I doing wrong?


Does your custom TreeModel implement valueForPathChanged()?

HTH,
Ray

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: fishfry | last post by:
I'm using a TreeModel to represent a filesystem directory tree for presentation by a JTree. The first level of the directory appears fine, but when I click on any of the little triangles to expand...
0
by: Steven Brown | last post by:
I'm trying to figure out how to safely use .NET events/delegates in a thread-safe class. There are a couple problems. One is that the standard "if(EventName != null) EventName(...);" call can...
5
by: knocte | last post by:
Hello. I am a web developer very worried about "bloat code" and "languages mixture". So, since some time, I always try to avoid completely the use of javascript in XHTML/HTML files. This leads...
2
by: Jon Davis | last post by:
The garbage handler in the .NET framework is handy. When objects fall out of scope, they are automatically destroyed, and the programmer doesn't have to worry about deallocating the memory space...
0
by: Efim | last post by:
Hi, I have got some problem with sending of events in .NET. I am using remouting. The client has got 2 objects for receiving different types of events (responses and events) The server has got...
2
by: glenn | last post by:
I have a very serious problem with my forms and components that I was wondering if there was a way to turn off. The problem is as follows: 1) create a form and place 50 components on the form...
12
by: scsharma | last post by:
Hi, I am working on creating a webapplication and my design calls for creating main webform which will have menu bar on left hand side and a IFrame which will contain all the forms that are shown...
30
by: Burkhard | last post by:
Hi, I am new to C# (with long year experience in C++) and I am a bit confused by the language construct of events. What is it I can do with events that I cannot do with delegates? At the moment...
3
by: daan | last post by:
Hello, I have a problem and I can't get the solution for it :( I have a com dll, which i imported as a reference. The com object is part of a class which is multithreaded and will create...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.