Sam
Sam

Reputation: 466

Right to Left Shell in SWT

I want to mirror (Right to Left mode) the title bar control buttons (close, minimize and maximize buttons) using SWT in Java. I searched everywhere and came across this link but it does not work for me.

Please help me.

Upvotes: 1

Views: 258

Answers (2)

Rüdiger Herrmann
Rüdiger Herrmann

Reputation: 20985

In order to explicitly change the orientation of an SWT control, use

setOrientation( SWT.RIGHT_TO_LEFT );

It is also possible to pass the RIGHT_TO_LEFT style flag to the constructor, for example

new Shell( parent, SWT.DIALOG_TRIM | SWT.RIGHT_TO_LEFT );

Upvotes: 2

Georgian
Georgian

Reputation: 8960

A JFace Window will contain a SWT Shell when opened.

There is the Shell#setOrientation API (which is inherited from Control, btw). Use that to mirror you controls (check the javadoc).

/**
 * 
 * @author ggrec
 *
 */
public class Tester
{

    public static void main(final String[] args)
    {
        final Display display = new Display();
        final Shell shell = new Shell(display);
        shell.setLayout(new GridLayout(1, false));

        shell.setOrientation(SWT.RIGHT_TO_LEFT);

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

}

Upvotes: 0

Related Questions