1

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.

Rüdiger Herrmann
  • 20,512
  • 11
  • 62
  • 79
Sam
  • 446
  • 7
  • 17
  • Which version of SWT are you using? – Baz Jul 14 '15 at 09:34
  • I see you're new to SO. If you feel an answer solved the problem, please mark it as 'accepted' by clicking the green check mark. This helps keep the focus on older posts which still don't have answers. – Rüdiger Herrmann Jul 14 '15 at 10:31

2 Answers2

2

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 );
Rüdiger Herrmann
  • 20,512
  • 11
  • 62
  • 79
  • Since v3.7, SWT has a `setOrientation` method on `Control` (which `Shell` inherits from) – Rüdiger Herrmann Jul 14 '15 at 09:21
  • You are right. I used an old version of SWT. It works great now. Thanks a lot – Sam Jul 14 '15 at 10:29
  • @RüdigerHerrmann can you have a look [here]http://stackoverflow.com/questions/32816938/combobox-jface-showing-end-of-string-by-default-how-to-show-start-of-long-strin) – Saras Arya Oct 16 '15 at 10:56
0

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();
    }

}
Georgian
  • 8,795
  • 8
  • 46
  • 87