Updating a jtree Freaky web chat
So there is still the old text visible, but if you select that node/text there is also the added ' - Updated! I've tried to fix this with Visible(true) , this.update UI(), this.validate(),... Here is the code sequence: The user object is updated and the Cell Renderer (a JLabel) is updated.Now you will need to tell the tree model that the tree node is updated.Take a look at the Java Tutorial section on how to use trees, especially the cell renderer stuff at And kawaii, I would think you need to work with a Mouse Listener to find the click events and have your tree node respond.To enable right click (mouse button number 2) editing in a tree, I used public void mouse Pressed(Mouse Event me) HTH, Joe Kawaii, Joe, many thanks for your help.tree.scroll Path To Visible(new Tree Path) doesn't change anything, but the tutorial gave me some hints which will work - although they are really complicated.
(It should have changed, because it was changed in the menu and saved to the db.) By using My Tree Model Listener(); (thanks for the link, Joe), there is a way to solve the problem, but as already mentioned, it is not the romantic kind of way I've thought of: I could get the data by pressing 'Apply', format it in the nodes text way, get the nodes position (which may be the hardest part to work through, as the listener doesn�t provide the correct path to the node), Editable(true); tree.start Editing At Path(path); insert the changed data, Editing(); Editable(false); I would really appreciate every other way to achieve the node-update. [Joe, I don�t know in which way the Tree Cell Renderer classes may be useful, as I am already extending Default Tree Cell Renderer to customize the nodes icons and there seems to be no way to change the nodes text. ] I'll light a candle for everyone, who can help me out of this and solve the problem! Tom Well, Default Tree Cell Renderer extends JLabel, which does let you call set Text().
One can select a node (its text is retrieved from the db), press a key or a button and - whow!