Skip to main content

RE: JTreeTable not responding to tree events

No replies
Anonymous

Just as a note: even if you have an immutable treetable, the first column in the JTreeTable must be editable -- otherwise the tree expand/contract events get disgarded.

So, make sure your TreeTableModel returns true if the cell is in column 0 (the tree column) even if the TreeTable is immutable.

-jonathan

-----Original Message-----
From: jdnc-interest@javadesktop.org [mailto:jdnc-interest@javadesktop.org]
Sent: Friday, August 13, 2004 7:45 AM
To: jdnc@jdnc.dev.java.net
Subject: Re: JTreeTable not responding to tree events

> Hi, I have extended the AbstractTreeTableModel and
> created my own model. When I run the program I can
> see the tree. However, when I try to click on any
> node to expand, nothing happens. I haven't added any
> listeners myself. I am assuming I don't need to
> explicitly code for the default expand and collapse
> functionality (as long as I implement the
> getChildCount, getChild, isLeaf and a bunch of
> methods in the TreeTableModel. What am I missing?
>
> thanks
> Siva

Are you passing your custom TreeTableModel to the constructor for JXTreeTable, or through JXTreeTable.setTreeTableModel()?

A TreeTableModel is fundamentally a TreeModel, in that it does not have any table model functionality. JXTreeTable internally creates a TreeTableModelAdapter that adapts a TreeTableModel (basically a
TreeModel) into a TableModel for use with JXTreeTable (basically a JTable).

TreeTableModelAdapter installs the necessary TreeModelListeners and TreeExpansionListeners, so you don't have to. Also, you are correct in assuming that you don't have to explicitly code for the
default expand/collapse functionality.

Have you tried putting breakpoints in isCellEditable()? JXTable.isCellEditable() will call TreeTableModelAdapter.isCellEditable(), which, in turn, will call isCellEditable in AbstractTreeTableModel.

All of these methods must return true for node expansion/collapse to work. Please let me know what you find as a result of these breakpoints.

Ramesh
---
[Message sent by forum member 'rameshgupta' (Ramesh Gupta)]

http://www.javadesktop.org/forums/thread.jspa?messageID=22661&#22661

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

==============================================================================

If you are not an intended recipient of this e-mail, please notify
the sender, delete it and do not read, act upon, print, disclose,
copy, retain or redistribute it.

Click here for important additional terms relating to this e-mail.

==============================================================================

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net