如何正确对齐Java SWT
应用程序中的复选框?这是我的代码片段:
Button checkFullECR = new Button(scrolledForm.getBody(), SWT.CHECK);
checkFullECR.setAlignment(SWT.RIGHT);
checkFullECR.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
checkFullECR.setText("I need the complete ECR/ECN Process:");
如下所示:
[ ] I need the complete ECR/ECN Process:
我希望它看起来像:
I need the complete ECR/ECN Process: [ ]
答案 0 :(得分:5)
仅使用Button
控件无法执行此操作,您需要使用Label
作为文本,使用复选框Button
,不要将文字排列在两列中。< / p>
类似的东西:
Composite body = new Composite(parent, SWT.NONE);
body.setLayout(new GridLayout(2, false));
Label label = new Label(body, SWT.LEFT);
label.setText("I need the complete ECR/ECN Process:");
Button checkFullECR = new Button(body, SWT.CHECK);
... more label / button pairs ....