我的对话框有两个TreeViewer
组件。垂直滚动条必须同步。
我尝试了setSelection
和setTopItem
方法,但是对其他树都没有影响。
xViewerLeft = createXViewer(leftComposite, this);
xViewerRight = createXViewer(rightComposite, this);
xViewerLeft.getTree().getVerticalBar().addListener(SWT.Selection, new Listener() {
@Override public void handleEvent(Event arg0) {
//xViewerRight.getTree().setSelection(xViewerLeft.getTree().getSelection());
//xViewerRight.getTree().setTopItem(xViewerLeft.getTree().getTopItem());
}
});
有任何想法吗?
最佳答案
解决方案:
vBar1.addListener(SWT.Selection, new Listener() {
@Override public void handleEvent(Event arg0) {
double y = vBar1.getSelection()*xViewerRight.getTree().view.bounds().height/100;
NSPoint nsPoint = new NSPoint();
nsPoint.x = 0;
nsPoint.y = y;
xViewerRight.getTree().view.scrollPoint(nsPoint);
}
});
关于java - 滚动TreeViewer树SWT,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8347737/