Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jtree to JPanel

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.

like image 883
Okan Çetin Avatar asked Jan 15 '12 03:01

Okan Çetin


1 Answers

Something like:

JPanel p = new JPanel(new BorderLayout());
JScrollPane sp = new JScrollPane(jtree);
p.add(BorderLayout.CENTER, sp);
like image 128
Tom Avatar answered Oct 11 '22 23:10

Tom