我有一个如下所示的 UI。
我在这里要做的是在开始时初始化整个 UI,并relayout()
在用户填写一些输入时调用该方法。这里的问题是,如果我的内容(此处的“名称”)占用更多空间,则应该显示滚动条并让用户滚动以便他们可以看到数据,但滚动条不会显示在全部。
protected void initializeFrame() {
setLayout(new FillLayout());
mainComposite = new Composite(this, SWT.NONE);
mainComposite.setBackground(getBackground());
GridLayout layout = new GridLayout(2, false);
mainComposite.setLayout(layout);
GridData data = new GridData();
data.horizontalAlignment = GridData.FILL;
data.grabExcessHorizontalSpace = true;
data.horizontalSpan = 2;
headingComposite = new Composite(mainComposite, SWT.BORDER);
headingComposite.setBackground(getBackground());
headingComposite.setLayoutData(data);
scrolledComposite = new ScrolledComposite(mainComposite, SWT.V_SCROLL| SWT.H_SCROLL);
scrolledComposite.getVerticalBar().setIncrement(10);
scrolledComposite.getVerticalBar().setPageIncrement(100);
scrolledComposite.getHorizontalBar().setIncrement(10);
scrolledComposite.getHorizontalBar().setPageIncrement(100);
scrolledComposite.setExpandHorizontal(true);
scrolledComposite.setExpandVertical(true);
data = new GridData(GridData.FILL_BOTH );
data.widthHint = 500;
scrolledComposite.setLayoutData(data);
leftEditorComposite = new Composite(scrolledComposite, SWT.BORDER);
leftEditorComposite.setBackground(getBackground());
scrolledComposite.setContent(leftEditorComposite);
data = new GridData(GridData.FILL_BOTH);
data.widthHint = 150;
rightEditorComposite = new Composite(mainComposite, SWT.BORDER);
rightEditorComposite.setBackground(getBackground());
rightEditorComposite.setLayoutData(data);
}
public void relayout() {
scrolledComposite.setMinSize(leftEditorComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
}
谁能告诉我这里有什么问题?