Java 如何向JFace对话框的按钮栏添加新按钮

Java 如何向JFace对话框的按钮栏添加新按钮,java,dialog,swt,jface,Java,Dialog,Swt,Jface,我需要一个按钮,以不断地放在我的JFace对话框的左下角,即使在重新调整对话框的大小 我已重写createButtonsForButtonBar()的 我希望示例按钮放在左下角,后面是空格,然后是ok,cancel 如何实现这一点?Eclipse关于对话框就是这样做的: protected void createButtonsForButtonBar(Composite parent) { // Change parent layout data to fill the whole bar

我需要一个按钮,以不断地放在我的JFace对话框的左下角,即使在重新调整对话框的大小

我已重写createButtonsForButtonBar()的

我希望示例按钮放在左下角,后面是空格,然后是ok,cancel


如何实现这一点?

Eclipse关于对话框就是这样做的:

protected void createButtonsForButtonBar(Composite parent)
{
  // Change parent layout data to fill the whole bar
  parent.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

  sampleButton = createButton(parent, IDialogConstants.NO_ID, "Sample", true);

  // Create a spacer label
  Label spacer = new Label(parent, SWT.NONE);
  spacer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

  // Update layout of the parent composite to count the spacer
  GridLayout layout = (GridLayout)parent.getLayout();
  layout.numColumns++;
  layout.makeColumnsEqualWidth = false;

  createButton(parent, IDialogConstants.OK_ID,"OK", false);
  createButton(parent, IDialogConstants.CANCEL_ID,"Close", false);
}
protected void createButtonsForButtonBar(Composite parent)
{
  // Change parent layout data to fill the whole bar
  parent.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

  sampleButton = createButton(parent, IDialogConstants.NO_ID, "Sample", true);

  // Create a spacer label
  Label spacer = new Label(parent, SWT.NONE);
  spacer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

  // Update layout of the parent composite to count the spacer
  GridLayout layout = (GridLayout)parent.getLayout();
  layout.numColumns++;
  layout.makeColumnsEqualWidth = false;

  createButton(parent, IDialogConstants.OK_ID,"OK", false);
  createButton(parent, IDialogConstants.CANCEL_ID,"Close", false);
}