gpt4 book ai didi

java - 滚动 TreeViewer 树 SWT

转载 作者:行者123 更新时间:2023-12-01 06:24:48 25 4
gpt4 key购买 nike

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

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com