我使用下面的代码来组合两个画布。
public static void main(String[] args) {
final Display display = new Display();
final Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
shell.setText("Canvas Test");
Composite mainComp = new Composite(shell, SWT.NONE);
GridLayout layout = new GridLayout(2, false);
layout.horizontalSpacing = 0;
mainComp.setLayout(layout);
mainComp.setLayoutData(new GridData(SWT.BEGINNING, SWT.TOP, true, true));
final Canvas hwCanvas = new Canvas(mainComp, SWT.NO_REDRAW_RESIZE | SWT.V_SCROLL);
hwCanvas.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
hwCanvas.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
hwCanvas.setLayoutData(new GridData(SWT.BEGINNING, SWT.TOP, false, true));
hwCanvas.getVerticalBar().setVisible(false);
final Canvas traceCanvas = new Canvas(mainComp, SWT.NO_REDRAW_RESIZE | SWT.H_SCROLL | SWT.V_SCROLL);
traceCanvas.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
traceCanvas.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
traceCanvas.setLayoutData(new GridData(SWT.BEGINNING, SWT.TOP, true, true));
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
是否可以增加水平滚动条的宽度(长度),如此处所示 快照