开发者

How to add JTree dynamically to a created JScrollPane?

开发者 https://www.devze.com 2023-02-11 06:41 出处:网络
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.

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开发者_StackOverflow社区 to the JScrollpane using

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

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


direct variant of the same:

 scroll.setViewportView(jTree)


scroll.getViewport().add(jTree)

0

精彩评论

暂无评论...
验证码 换一张
取 消