• Post Reply Bookmark Topic Watch Topic
  • New Topic

Tree problem  RSS feed

 
Andreas Johansson
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
I have some problems with getting an editable tree to work correctly. It's a tree where you can add, rename and delete nodes. You should also be able to edit a node name and then use the mouse to click outside of the tree to save the changes instead of pressing return. Most of it works, almost.
The problem is that I don't quite understand the use of the CellEditorListener and its methods editingCanceled and editingStopped. What should be done in them and why are both called?
Does anyone have some link to some page describing mutable trees in swing or solved the same problem? Or any book to recommend (for java 1.3).
I hope someone can help!
/Andreas
 
George Thomas
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I recommend Java Swing, Eckstein, Loy, Wood (O'Reilly).
 
eric moon
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I understand it, the cellEditor is an impermanent object that gets created when you edit the text of one of the nodes in your tree.
How are you renaming nodes? This is where I would expect you to need to understand the cell editor. I thought that what ever you wanted to happen when you type into a cell (i.e rename the node) would get put into the editingStopped method. Am I confused???
[This message has been edited by eric moon (edited May 15, 2001).]
 
Andreas Johansson
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

How are you renaming nodes? This is where I would expect you to need to understand the cell editor. I thought that what ever you wanted to happen when you type into a cell (i.e rename the node) would get put into the editingStopped method. Am I confused???

I edit nodes both when adding and renaming nodes because when the user press the Add button a new empty node is inserted in the tree to be named.
My first impression was that editingStopped should be called when you press return and editingCanceled when you pressed escape. But it seems like both of them are called, in both cases, but in different order. Might be that my code is doing things in the wrong way of course...
What is the difference of a DefaultCellEditor and a DefaultTreeCellEditor? Do I need to use both? Or which one? Why?
Thank you for your answer!
/Andreas
 
John Zukowski
Author
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I used to like the O'Reilly Swing book but it hasn't been updated since 98 (except for fixing up the package names). I think my Swing book is the only one updated for 1.3, or at least I haven't seen any of the other offerings updated yet. Wrox's Professional Java Programming book has some decent Swing coverage for 1.3, it just isn't a Swing-specific book.
------------------
John Zukowski Author of "Definitive Guide to Swing for Java 2" and "Java Collections"
 
Sanjay Bahrani
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi There,
I am giving you the link for the Examples of JTree, I hope this will be helpful for you.
www2.gol.com/users/tame/swing/examples/SwingExamples.html
bye...
 
Andreas Johansson
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I used to like the O'Reilly Swing book but it hasn't been updated since 98 (except for fixing up the package names). I think my Swing book is the only one updated for 1.3, or at least I haven't seen any of the other offerings updated yet. Wrox's Professional Java Programming book has some decent Swing coverage for 1.3, it just isn't a Swing-specific book.

Okay, thanks for your post with book recomendations. Does your own book include an in depth coverage of Trees in Swing, since that is my problem right now? Editable trees?
/Andreas
 
John Zukowski
Author
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My Trees chapter is about 70 pages and includes editing coverage. To get a feel for my style of writing, you can read the Tables chapter from the Swing book at http://www.apress.com/books/sampleChapters/189311578X.pdf
The Wrox book I mentioned has about 50 pages on trees.
You can also read a review of my Swing book at http://www.webbuildermag.com/free/bookrevview.asp?content_id=536
------------------
John Zukowski Author of "Definitive Guide to Swing for Java 2" and "Java Collections"
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!