• Post Reply Bookmark Topic Watch Topic
  • New Topic

Creating new leaves in tree  RSS feed

 
Nigel Hoath
Greenhorn
Posts: 19
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Having trouble adding leaves to my tree. Developing a stand alone Java app using mainly SWT and Eclipse JavaEE on Windows.

The tree is like this:

root
------parentA
--------------childA1
--------------childA2
--------------childA3
------parentB
------parentC
--------------childC1
--------------childC2

My requirement: when a child is selected/clicked I want to create a grandchild (there could be from zero to say 12 grandchildren). Thus if user clicks/selects childA2:

root
------parentA
--------------childA1
--------------childA2
----------------------grandchildA21
--------------childA3
------parentB
------parentC
--------------childC1
--------------childC2

Codewise I have:



Question one: do I need any further tree related imports to get this to work?



Tree displays, is expandable, has all the right text.
.


And it is here I've tried lots of options but it's like bleak mid winter - no new leaves What seems odd is that I can see the selected/clicked child text item.getText() but if I look at the index it is always -1. And I thought the index would let me create the leaf.

Question 2: If anyone can give me any guidance or link to a good example that actually works while I still have hair it would be greatly appreciated.

Cheers
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do not work in SWT. Maybe you will find the Swing version useful, http://docs.oracle.com/javase/tutorial/uiswing/components/tree.html#dynamic
 
Nigel Hoath
Greenhorn
Posts: 19
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maneesh Godbole wrote:I do not work in SWT. Maybe you will find the Swing version useful, http://docs.oracle.com/javase/tutorial/uiswing/components/tree.html#dynamic


Maneesh well with the lack of responses here and a host of incoherent examples on the net I guess my choosing SWT for a tree was a bad idea. For sure the examples for swing seem to be intuitive to some degree.

As I only have two trees in my partly developed project I think I'll switch over to swing. Cheers for the reply.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In case you haven't done so already, you might want to try asking SWT questions over at the SWT forum https://www.eclipse.org/forums/index.php/f/100/
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!