SWT:组

时间:2017-08-21 11:19:43

标签: java swt jface

我希望grpModelProperties的高度更低。对于组中文本框的上方和下方的距离,我该怎么办?

public void createControl(Composite parent) {

     Composite composite = new Composite(parent, SWT.NULL);
     composite.setLayout(new FillLayout());

     Group grpModelProperties = new Group(composite, SWT.SHADOW_IN);
     grpModelProperties.setText("ETL Transformation Model");
     grpModelProperties.setLayout(new GridLayout(2, false));


     GridData data = new GridData(GridData.FILL_HORIZONTAL);
     text = new Text(grpModelProperties, SWT.NONE);
     text.setLayoutData(data);

     Button button = new Button(grpModelProperties, SWT.PUSH);
     button.setText("File System...");
     button.addSelectionListener(new SelectionAdapter() {
     public void widgetSelected(SelectionEvent e) {
     FileDialog dialog = new FileDialog(getShell(), SWT.NULL);
     String path = dialog.open();

     if (path != null) {
     File file = new File(path);
     if (file.isFile())
      displayFiles(new String[] { file.toString()});
      else
      displayFiles(file.list());

     }
}

1 个答案:

答案 0 :(得分:3)

您已为包含FillLayout的{​​{1}}指定了Composite,因此正在拉伸该组以填充对话框区域。

为复合材料使用不同的布局:

Group

我在这里使用了Composite composite = new Composite(parent, SWT.NULL); composite.setLayout(new GridLayout()); Group grpModelProperties = new Group(composite, SWT.SHADOW_IN); grpModelProperties.setText("ETL Transformation Model"); grpModelProperties.setLayout(new GridLayout(2, false)); // Layout data for the group in the composite, // Fill the row, stays at the top of the dialog grpModelProperties.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); 并为该组设置GridLayout以填充该行。