简体   繁体   中英

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.

直接变体:

 scroll.setViewportView(jTree)

scroll.getViewport()。添加(JTree的)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM