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

时间:2012-11-26 16:15:51

标签: 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;

org.eclipse.swt.widgets.Composite;

1 个答案:

答案 0 :(得分:5)

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

一些有用的snippets can be found here