Skip to main content

Editable JTree in JTreeTable

1 reply [Last post]
Anonymous

All-

In the JTreeTable, the first column needs to be editable to allow the Jtree to expand and contract. The problem is that I cant seem to get the JTree to be non-Editable. So when you click twice on a
Tree node, the Jtree goes into edit mode.

I've tried everything that seems reasonable, but I must be missing something. I set the Jtree.editable = false, the model returns false for editing, and I even got a little hacky with the UI code just
to see if I could block the edits.

Any clue what I'm missing?

-jonathan

-----Original Message-----
From: jdnc-interest@javadesktop.org [mailto:jdnc-interest@javadesktop.org]
Sent: Wednesday, August 11, 2004 3:32 PM
To: jdnc@jdnc.dev.java.net
Subject: Re: RE: RE: RE: Setting editor/renderer for JTreeTable

> > Glad to hear that you got your existing code to
> > work with JDNC!
>
> I did get it to work -- but it required me to extend
> a UI class, write my own treeCellRenderer, and modify
> the source of JTreeTable itself... not exactly an
> easy experience.
>
> But I *am* using it :)
>
> -jonathan

Why UI class? Also, we'd like you to share your experience with us in greater detail, if possible, so that we can avoid baking in some of our mistakes into the final api.

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

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

---------------------------------------------------------------------
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

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
rameshgupta
Offline
Joined: 2004-06-04
Points: 0

> In the JTreeTable, the first column needs to be
> editable to allow the Jtree to expand and contract.
> The problem is that I cant seem to get the JTree to
> be non-Editable. So when you click twice on a
> Tree node, the Jtree goes into edit mode.
>
> I've tried everything that seems reasonable, but I
> must be missing something. I set the Jtree.editable =
> false, the model returns false for editing, and I
> even got a little hacky with the UI code just
> to see if I could block the edits.
>
> Any clue what I'm missing?
>
> -jonathan

Jonathan,

It is our api that is missing something -- in this case, the ability to expand/collapse nodes in a treetable without allowing node label to be edited. Thanks for pointing this out.

The quick fix for you (since you're already working on a copy of the sources) is to simply return null from TreeTableCellEditor.getTableCellEditorComponent();

A permanent fix should probably take the following shape:

Instead of TreeTableCellEditor extends DefaultCellEditor,
we will have TreeTableCellExpansionController extends DefaultCellEditor. This would look identical to what the current TreeTableCellEditor looks like, except that the
getTableCellEditorComponent() method would return a label instead of an edit field.

Then, TreeTableCellEditor would extend TreeTableCellExpansionController, and only override the getTableCellEditorComponent() method with what it currently has.

Finally, JXTreeTable should define a boolean property that controls whether the *label* of hierarchical nodes is editable. If so, it should install TreeTableCellEditor. Otherwise, it should install TreeTableCellExpansionController.

Ramesh