5

I have a JTree object which uses DefaultTreeModel as model and I add/remove nodes respect to that model.

At that point, I need to show tree structure in graphical interface such as JPanel. How can I map DefaultTreeModel elements into Jpanel object? In other words, how can I draw JTree objects into JPanel object. Since tree can be modified, implementation should reflect the changes.

Thanks for your care.

Okan Çetin
  • 85
  • 1
  • 4

1 Answers1

5

Something like:

JPanel p = new JPanel(new BorderLayout());
JScrollPane sp = new JScrollPane(jtree);
p.add(BorderLayout.CENTER, sp);
Tom
  • 43,583
  • 4
  • 41
  • 61
  • Thanks for reply but problem is little different. I want to show each elements of JTree as individual JPanel object and draw them in tree structure like binary tree. – Okan Çetin Jan 15 '12 at 06:16
  • So each on its own JPanel or all in one JPanel? – Tom Jan 15 '12 at 08:36