我有2个按钮的滚动
我如何设置按钮的顺序将是相同的原始而不是每个控件:按钮滚动和按钮将在不同的行
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));
答案 0 :(得分:1)
您是否阅读过我在其他一个问题中发布的有关SWT布局的文章?
Display
和Shell
是您要创建的第一件事。之后,您可以向shell
添加内容。
您的问题是基于这样一个事实:您创建的GridLayout
只有一列。因此,所有小部件都在彼此之下。
layout= new GridLayout(1, false);
第一个参数是列数。将其设置为3列三列。
在提出进一步的问题之前,请先阅读布局文档和文章Understanding layouts in SWT。它一定会帮到你。