File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Treetable events Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Treetable events" Watch "Treetable events" New topic

Treetable events

Catherine Dunn

Joined: Feb 10, 2006
Posts: 4

I am trying to create a treetable that displays numerical data. I want the user to be able to edit the data in the treetable by clicking on a cell and entering a new value. I figured out how to create the treetable and treetable model, but I can't figure out how to do the event handling. I read somewhere that I need to extend DefaultCellEditor, but I haven't been able to figure out how to do that.

I have studied the three-part Sun treetable tutorial:

I also found this post on JavaRanch

It was very helpful in terms of constructing the treetable model, but it didn't address event handling. A push in the right direction would be much appreciated.

Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
The bookmarks example ( in the third article runs okay and allows user–editing of the URLs in the "Location" column. I compiled it in j2se 1.5 with these changes:
1 — changed the deprecated show method to setVisible at the end of the TreeTableExample3 constructor
2 — in the getValueAt method of the DynamicTreeTableModel class: j2se 1.5+ has the "varargs" feature so change the "null" values to zero–length arrays in the reflection methods:

This second change should not be necessary in older versions.
Catherine Dunn

Joined: Feb 10, 2006
Posts: 4
Thank you, thank you, thank you!

This problem has been driving me crazy!
I agree. Here's the link:
subject: Treetable events
It's not a secret anymore!