java - 如何右对齐 Java SWT 应用程序中的复选框

标签 java checkbox alignment swt

如何右对齐 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:       [ ]

最佳答案

仅使用 Button 控件无法做到这一点,您需要使用 Label 作为文本和复选框 Button没有文本排列在两列中。

类似于:

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 ....

关于java - 如何右对齐 Java SWT 应用程序中的复选框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31995914/

相关文章:

java - 解析 java.lang.String 类型的 data.org.json.JSONException 值时出错,无法转换为 JSONArray

java - 如何使用 Apache poi 库保护 XSSFWorkbook 中的工作表?

java - 引文 : which solution I should use for tests with JPA?

css - anchor 标记内的垂直对齐文本

java 字符 '\249' "not a statement"和 "unclosed character literal"

c# - 将列表框中的值添加到数据库

string - 从单元格中的字符串中删除重复项

php - 表单助手 Cake PHP 中的复选框

html - 如何将文本与其他文本水平对齐?

c - GCC 和 G++ struct packing 的区别?