是否有可能使SWT中的复选框符号顶部对齐?当前,复选框符号垂直居中。但是我想把它放在首位。
谢谢
最佳答案
有可能的:
public class Test {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setMinimumSize(1, 1);
shell.setLayout(new GridLayout(2, false));
Composite left = new Composite(shell, SWT.NONE);
left.setLayout(new GridLayout(1, false));
GridData gd = new GridData();
gd.verticalAlignment = SWT.TOP;
left.setLayoutData(gd);
new Button(left, SWT.CHECK);
Composite right = new Composite(shell, SWT.NONE);
right.setLayout(new GridLayout(1, false));
Label label = new Label(right, SWT.WRAP);
label.setText("Lorem inpsum. Lorem inpsum. Lorem inpsum.\n Lorem inpsum. Lorem inpsum. Lorem inpsum. \nLorem inpsum. Lorem inpsum.\n Lorem inpsum. Lorem inpsum. Lorem inpsum. Lorem inpsum. Lorem inpsum. Lorem inpsum.\n Lorem inpsum. Lorem inpsum. Lorem inpsum.\n Lorem inpsum. Lorem inpsum. ");
GridData gd2 = new GridData();
gd2.verticalAlignment = SWT.TOP;
label.setLayoutData(gd2);
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
}
如果您有另一种创建窗口小部件的方法,并且想要按照说明进行工作,则需要发布一些代码段。