0
我想添加一个复合到Eclipse,当某个复选框被选中时出现。该复合材料将由两部分组成:WARNING_ICON和带有文本的标签。SWT排队ICON_WARNING与标签
我似乎无法得到布局非常正确 - 我想显示的图像和标签并排。这里是我的代码段:
final Composite warningComposite = new Composite(parent, SWT.NONE);
warningComposite.setLayout(new GridLayout(2, false));
warningComposite.setLayoutData(new GridData(0, 0, true, false));
Label l = SWTUtilities.createLabel(composite, "", -1, -1, 1, GridData.BEGINNING);
final Image img = PlatformUI.getWorkbench().getDisplay().getSystemImage(SWT.ICON_WARNING);
l.setImage(img);
l.setLayoutData(new GridData());
l = SWTUtilities.createLabel(composite, "Wizards Gone Wild", -1, -1, 1, GridData.END);
而且SWTUtilities.createLabel方法:
public static Label createLabel(final Composite parent, final String label, final int width, final int indent, final int span, final int style) {
Assert.isNotNull(parent);
Assert.isNotNull(label);
final Label control = new Label(parent, SWT.WRAP);
control.setText(label);
if (width > 0 || indent > 0 || span > 0) {
final GridData data = new GridData(style);
if (width > 0)
data.widthHint = width;
if (indent > 0)
data.verticalIndent = indent;
if (span > 1)
data.horizontalSpan = span;
control.setLayoutData(data);
}
return control;
}