复合材料在ScrolledCompsite中被截断

时间:2016-12-22 04:19:17

标签: swt

在下面的代码中,我在ScrolledComposite中提供了2000个标签。但我看到只有1400多个标签。我发现这是由于操作系统的限制。我需要使用canvas的解决方法。

    Display display = new Display();
    Shell parent = new Shell(display);
    parent.setLayout(new GridLayout(1, false));
    parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    final ScrolledComposite scrolledComposite = new ScrolledComposite(parent,
            SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    scrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    scrolledComposite.setExpandHorizontal(true);
    scrolledComposite.setExpandVertical(true);
    final Composite childComposite = new Composite(scrolledComposite, SWT.NONE);
    scrolledComposite.setContent(childComposite);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    childComposite.setLayout(layout);
    for (int i = 0; i < 2000; i++) {
        Label label = new Label(childComposite, SWT.BORDER);
        label.setText("Label " + i);
    }
    Point size = childComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    scrolledComposite.setMinSize(size);
    parent.setSize(parent.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, 200);
    parent.open();
    while (!parent.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();`

enter image description here

0 个答案:

没有答案