我尝试在SWT中绘制类似Likert量表的东西。原型看起来像这样:
这或多或少都有效,但我想拉伸顶行,其中打印数字1,2,3,4,5和6以进行拉伸,以使该组具有与两者相同的大小下面的单选按钮组。我根本不知道该怎么做。
这是我到目前为止的代码:
@Override
protected Control createDialogArea(Composite parent) {
Composite area = (Composite) super.createDialogArea(parent);
Composite container = new Composite(area, SWT.NONE);
GridLayout layout = new GridLayout(3, false);
container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
container.setLayout(layout);
createRatingView(container);
return area;
}
private void createRatingView(Composite container) {
new Label(container, SWT.NONE);
new Label(container, SWT.NONE);
Group r = new Group(container, SWT.END);
r.setLayout(new FillLayout(SWT.HORIZONTAL));
new Label(r, SWT.NONE).setText("1");
new Label(r, SWT.NONE).setText("2");
new Label(r, SWT.NONE).setText("3");
new Label(r, SWT.NONE).setText("4");
new Label(r, SWT.NONE).setText("5");
new Label(r, SWT.NONE).setText("6");
List<A> methods = B.getElements(currentObj);
for (A method : methods) {
Label element = new Label(container, SWT.NONE);
element.setText(method.getMode().name());
Label name = new Label(container, SWT.NONE);
name.setText(method.getName());
Group group = new Group(container, SWT.SHADOW_ETCHED_OUT);
group.setLayout(new RowLayout(SWT.HORIZONTAL));
new Button(group, SWT.RADIO).setData(1);
new Button(group, SWT.RADIO).setData(2);
new Button(group, SWT.RADIO).setData(3);
new Button(group, SWT.RADIO).setData(4);
new Button(group, SWT.RADIO).setData(5);
new Button(group, SWT.RADIO).setData(6);
}
}