如何修复 SWT 中按钮的顺序? [英] how to fix the order of the buttons in SWT?
问题描述
我有 2 个按钮的滚动条
I have scroller with 2 buttons
如何设置按钮的顺序将在相同的原始数据中而不是每个控件中:按钮滚动条和按钮将在不同的行中
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));
推荐答案
您是否阅读了我在您的其他问题之一中发布的有关 SWT 布局的文章?
Did you read the article about SWT layouts that I posted in one of your other questions?
Display
和 Shell
是首先要创建的东西.之后,您可以向 shell
添加内容.
The Display
and Shell
are the first things to create. After that you can add things to the shell
.
您的问题是基于这样一个事实,即您创建了一个只有一列的 GridLayout
.因此,所有小部件都位于彼此下方.
Your problem is based on the fact, that you created a GridLayout
with just one column. Thus all widgets are below each other.
layout= new GridLayout(1, false);
第一个参数是列数.对于三列,将其设置为 3.
The first parameter is the number of columns. Set it to 3 for three columns.
请阅读布局和文章的文档:在提出进一步问题之前了解 SWT 中的布局.一定能帮到你.
Please read the documentation of the layout and the article: Understanding layouts in SWT before asking further questions. It will definitely help you.
这篇关于如何修复 SWT 中按钮的顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!