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