Q:

How do I right align the check box in my Java SWT application

How do I right align the check box in my Java SWT application ? Here is my code snippet:
    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:");

It looks like the following:
[ ] I need the complete ECR/ECN Process:

I want it to look like:
I need the complete ECR/ECN Process:       [ ]

A:

You can't do this using just a Button control, you will need to use a Label for the text and a checkbox Button with no text arranged in two columns.
Something like:
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 ....

A:

For once I kind of have to disagree with Greg.
You can use the setOrientation(int) method of the Button to force right-to-left layout:
public static void main(String[] args)
{
    Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setLayout(new GridLayout());

    Button button = new Button(shell, SWT.CHECK);
    button.setText("TEST");

    button = new Button(shell, SWT.CHECK);
    button.setOrientation(SWT.RIGHT_TO_LEFT);
    button.setText("TEST");

    shell.pack();
    shell.open();

    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
        {
            display.sleep();
        }
    }

    display.dispose();
}

Looks like this:

(Tested on Linux Mint and Windows. Does not work on the Mac.)

