简体   繁体   English

SWT中从右到左壳

[英]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. 我想使用Java中的SWT镜像(从右到左模式)标题栏控制按钮(关闭,最小化和最大化按钮)。 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 为了显式更改SWT控件的方向,请使用

setOrientation( SWT.RIGHT_TO_LEFT );

It is also possible to pass the RIGHT_TO_LEFT style flag to the constructor, for example 例如,也可以将RIGHT_TO_LEFT样式标志传递给构造函数

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

A JFace Window will contain a SWT Shell when opened. JFace Window在打开时将包含SWT Shell

There is the Shell#setOrientation API (which is inherited from Control , btw). Shell#setOrientation API(继承自Control ,btw)。 Use that to mirror you controls (check the javadoc). 使用它来镜像您的控件(检查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();
    }

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM