Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试使用setInput()方法定期更新 JFace TreeViwer 的输入。我也使用
setInput()
viewer.setExpandedElements(expandedElements); viewer.setExpandedTreePaths(expandedTreePaths);
保存树状态的方法。但每次setInput()调用 TreeViewer 后都会闪烁。如何避免闪烁?
实际输入是否发生变化?如果不是,您可以refresh()改为调用......或者理想情况下使用 TreeViewers 添加/删除/更新方法以避免重建整个树。
refresh()
您可以尝试viewer.getTree().setRedraw(false)在调用 to 之前调用setExpand,然后再调用viewer.getTree().setRedraw(true)。
viewer.getTree().setRedraw(false)
setExpand
viewer.getTree().setRedraw(true)