ExpandBar bar = new ExpandBar(this, SWT.V_SCROLL);
bar.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
ExpandItem item1 = new ExpandItem(bar, SWT.NONE, 0);
item1.setText(CORRANSWER);
item1.setControl(correctAnswerGroup);
item1.setImage(image);
正确答案小组的定义在此之前发生:
private void initCorrectAnswerGroup() {
Group correctAnswerGroup = new Group(bar, SWT.BORDER);
correctAnswerGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
true, 1, 1));
correctAnswerGroup.setLayout(new GridLayout(1, false));
(new Label(correctAnswerGroup, SWT.NONE)).setText(LABEL_TASK_TXT);
taskTxt = new StyledText(correctAnswerGroup, SWT.READ_ONLY
| SWT.V_SCROLL | SWT.H_SCROLL);
gdTaskTxt = new GridData(SWT.NONE, SWT.NONE, false, false, 1, 1);
gdTaskTxt.widthHint = 800;
gdTaskTxt.heightHint = 200;
taskTxt.setLayoutData(gdTaskTxt);
chooseAnswerTypeComposite = new Composite(correctAnswerGroup, SWT.NONE);
chooseAnswerTypeComposite.setLayoutData(new GridData(SWT.FILL,
SWT.NONE, true, false, 1, 1));
chooseAnswerTypeComposite.setLayout(new GridLayout(1, false));
Label answerTypeLabel = new Label(chooseAnswerTypeComposite, SWT.NONE);
answerTypeLabel.setLayoutData(new GridData(SWT.LEFT, SWT.NONE, true,
false, 1, 1));
answerTypeLabel.setText(LABEL_ANSWER_TYPE);
answerTypeCombo = new Combo(chooseAnswerTypeComposite, SWT.READ_ONLY);
answerTypeCombo.setLayoutData(new GridData(SWT.LEFT, SWT.NONE, true,
false, 1, 1));
answerTypeCombo.setItems(new String[] { ANSWER_TYPE_STANDARD,
ANSWER_TYPE_RULE });
(new Label(correctAnswerGroup, SWT.NONE)).setText(LABEL_CORRECT_ANSWER);
correctAnswerMsgTokenTextField = new TokenTextField(correctAnswerGroup,
true, false, true, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
GridData gdETxtCorrAnsMsg = new GridData(SWT.FILL, SWT.FILL, true,
false, 1, 1);
gdETxtCorrAnsMsg.heightHint = 40;
correctAnswerMsgTokenTextField.getText()
.setLayoutData(gdETxtCorrAnsMsg);
}
然而,ExpandBar的大小不正确。它水平和垂直切割小部件,根本不显示任何ScrollBars。 它尝试使用ExpandItem的setHeight方法,但我试过的似乎既不工作...... 如何使ExpandBar拉伸垂直于correctAnswerGroup的整个大小并水平显示ScrollBars?