1

我的对话框有两个TreeViewer组件。垂直滚动条必须同步。我尝试过使用setSelectionandsetTopItem方法,但都对其他树没有影响。

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());
    }
});

有任何想法吗?

4

1 回答 1

-2

解决方案:

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);
        }
    });
于 2011-12-04T09:37:25.347 回答