Java 如何在SWT中绘制Likert标尺?

Java 如何在SWT中绘制Likert标尺?,java,swt,Java,Swt,我试着在SWT中画一些像利克特刻度的东西。原型如下所示: 这或多或少是可行的,但我想拉伸最上面的一行,其中数字1、2、3、4、5和6打印为拉伸,以便此组与下面的两个单选按钮组具有相同的大小。我只是不知道怎么做 以下是我目前掌握的代码: @Override protected Control createDialogArea(Composite parent) { Composite area = (Composite) super.createDialogArea(parent);

我试着在SWT中画一些像利克特刻度的东西。原型如下所示:

这或多或少是可行的,但我想拉伸最上面的一行,其中数字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);
    }
}
@覆盖
受保护的控件createDialogArea(复合父级){
复合区域=(复合)super.createDialogArea(父级);
复合材料容器=新复合材料(面积,SWT.NONE);
GridLayout=新的GridLayout(3,false);
setLayoutData(新的GridData(SWT.FILL,SWT.FILL,true,true));
容器。设置布局(布局);
createRatingView(容器);
返回区;
}
私有void createRatingView(复合容器){
新标签(集装箱,SWT.无);
新标签(集装箱,SWT.无);
r组=新组(容器,SWT.END);
r、 设置布局(新的填充布局(SWT.水平));
新标签(r,SWT.NONE).setText(“1”);
新标签(r,SWT.NONE).setText(“2”);
新标签(r,SWT.NONE).setText(“3”);
新标签(r,SWT.NONE).setText(“4”);
新标签(r,SWT.NONE).setText(“5”);
新标签(r,SWT.NONE).setText(“6”);
列表方法=B.getElements(currentObj);
对于(一种方法:方法){
标签元素=新标签(容器,SWT.NONE);
element.setText(method.getMode().name());
标签名称=新标签(容器,SWT.NONE);
name.setText(method.getName());
组=新组(容器、SWT、阴影蚀刻);
group.setLayout(新行布局(SWT.HORIZONTAL));
新按钮(组,单选开关)。设置数据(1);
新按钮(组,单选开关)。设置数据(2);
新按钮(组,单选开关)。设置数据(3);
新按钮(组,单选开关)。设置数据(4);
新按钮(组,单选开关)。设置数据(5);
新按钮(组,单选开关)。设置数据(6);
}
}

标题和按钮使用一个6列网格布局将使它们排列整齐。谢谢,但是我如何将按钮排列成一组呢?