The moose likes Swing / AWT / SWT and the fly likes Subtree in JTree Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Subtree in JTree" Watch "Subtree in JTree" New topic

Subtree in JTree

Jeevan Anand

Joined: Jul 02, 2008
Posts: 13
JTree has root folder invisible. It has folders as child nodes of tree called A, B, C, D.

A, B can contain only leaf nodes.

C, D can contain child nodes as folder and those child folders will have leaf nodes.

The problem is I want C/D should be treated as single tree i.e. user can not move any leaf node of C/D tree to any other folder like A/B...that is 'p' can be moved to Folder2 but not to folder 'A'/ 'B'...How to make these type of settings??

Kindly help me.
[ July 02, 2008: Message edited by: Jeevan Anand ]
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
I tried to keep this simple to show/emphasize how to customize the drop behavior. There are so many possibilities that it's difficult to say much about it.

Edit: Most of the code in the TransferHandler was taken from the Drag and Drop tutorial.
[ July 04, 2008: Message edited by: Craig Wood ]
I agree. Here's the link:
subject: Subtree in JTree
It's not a secret anymore!