将滚动条添加到使用GridLayout的Composite

Kri*_*eni 2 java eclipse swt jface

我想将垂直滚动条添加到下面代码中出现的屏幕上.你能建议怎么做吗?

public class SampleDialog extends TrayDialog {

public SampleDialog(final Shell shell) {
    super(shell);
    this.shell = shell;

}


@Override
public void create() {
    super.create();

}

@Override
protected Control SampleDialog(final Composite parent) {
    final GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    parent.setLayout(layout);

    createSampleText(parent);

    createSampleCombo(parent);
}
} 

where:
org.eclipse.jface.dialogs.TrayDialog;
org.eclipse.swt.layout.GridLayout;
Run Code Online (Sandbox Code Playgroud)

org.eclipse.swt.widgets.Composite;

Waq*_*yas 5

您可以使用a ScrolledComposite作为对话框中所有子控件的主父级.

这里有一些有用的片段.