Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add JTree dynamically to a created JScrollPane?

MY Jtree component is created within a actionperformed function. But I've already created a Jscrollpane in the constructor and added it to the JFrame.

Now within the actionperformed function, I tried to add the dynamically created JTree to the JScrollpane using

JScrollpaneobject.add(JtreeObject);
JScrollpaneobject.revalidate();

But I am unable to see the Jtree on the Jscrollpane.

like image 747
Vamsi Emani Avatar asked Dec 22 '22 17:12

Vamsi Emani


1 Answers

direct variant of the same:

 scroll.setViewportView(jTree)
like image 97
kleopatra Avatar answered Dec 24 '22 05:12

kleopatra