1

Compound JTree Node allowing events to pass through to objects underneath

I went through the answer by @Jakub Zaverka ,which was pretty lucid.But what I could not understand is where is the code to create tree nodes (JTree ,food,sports,colors). Could someone explain how the nodes are created.

If I create a Node extending JPanel having a JButton and JLabel as fields ,can I set the node using the constructor of JTree which would be rendered and edited by the same custom renderer and editor.

Community
  • 1
  • 1
Sameer Sarmah
  • 1,052
  • 4
  • 15
  • 33
  • @Jakub Zaverka:Perhaps you would be the best person to answer the question.I would have commented my doubts on the original thread but my privilege to comment on others post is yet to unlock.Apologies for that, – Sameer Sarmah Nov 17 '13 at 02:29

1 Answers1

1

The default JTree constructor "Returns a JTree with a sample model." To get the sample model, the constructor invokes the protected method getDefaultTreeModel(), which returns a sample model that is "Used primarily for beanbuilders to show something interesting." The values you see are contained in the source. A related example is seen here.

trashgod
  • 203,806
  • 29
  • 246
  • 1,045