简体   繁体   English

如何确定SWT中按钮的顺序?

[英]how to fix the order of the buttons in SWT?

I have scroller with 2 buttons 我有2个按钮的滚动条

How i can set that the order of the buttons will be in the same raw and not each control : button scroller and button will be in different row 我如何设置按钮的顺序将在同一原始而不是每个控件中:按钮滚动器和按钮将在不同的行中

    fComposite= new Composite(composite, SWT.RIGHT_TO_LEFT);
    GridData layoutData= new GridData(SWT.FILL, SWT.RIGHT_TO_LEFT, true, false);
    fComposite.setLayoutData(layoutData);
    layout= new GridLayout(1, false);
    layout.marginHeight= 0;
    layout.marginWidth= 0;
    layout.horizontalSpacing= 0;
    layout.verticalSpacing= 0;

    fComposite.setLayout(layout);

    Display display = parent.getDisplay();
    Shell shell = parent.getShell(); 
    Button button = new Button(fComposite, SWT.LEFT);
    button.setText("Two"); //$NON-NLS-1$
    button.setImage(display.getSystemImage(ICON_1));    

    final Scale scale = new Scale (fComposite, SWT.BORDER);
    Rectangle clientArea = fComposite.getClientArea ();
    scale.setBounds (clientArea.x, clientArea.y, 200, 64);
    scale.setMaximum (5);
    scale.setPageIncrement (1);
    scale.setSelection(5);

    Button rButton = new Button(fComposite, SWT.RIGHT);
    rButton.setText("Two"); //$NON-NLS-1$
    rButton.setImage(display.getSystemImage(ICON_2));   

Did you read the article about SWT layouts that I posted in one of your other questions? 您是否读过我在其他问题之一中发布的有关SWT布局的文章?

The Display and Shell are the first things to create. DisplayShell是首先要创建的东西。 After that you can add things to the shell . 之后,您可以将内容添加到shell

Your problem is based on the fact, that you created a GridLayout with just one column. 您的问题基于以下事实:您创建的GridLayout仅包含一列。 Thus all widgets are below each other. 因此,所有小部件都位于彼此下方。

layout= new GridLayout(1, false);

The first parameter is the number of columns. 第一个参数是列数。 Set it to 3 for three columns. 将其设置为3(三列)。

Please read the documentation of the layout and the article: Understanding layouts in SWT before asking further questions. 在询问其他问题之前,请阅读布局文档和文章: 了解SWT中的布局 It will definitely help you. 肯定会对您有帮助。

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

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