简体   繁体   English

如何在JFace对话框的按钮栏中添加新按钮

[英]How to add a new button to buttons bar of JFace dialog

I need a button to be constantly placed at the bottom left corner of my JFace dialog even on re size of dialog. 我需要一个按钮不断放在我的JFace对话框的左下角,即使在对话框的大小上也是如此。

I have overridden the createButtonsForButtonBar() 我重写了createButtonsForButtonBar()

protected void createButtonsForButtonBar(Composite parent)
{
    sampleButton = createButton(parent, IDialogConstants.NO_ID, "Sample", true);
    createButton(parent, IDialogConstants.OK_ID,"OK", false);
    createButton(parent, IDialogConstants.CANCEL_ID,"Close", false);
}

I want the sample button to be placed at the bottom left, followed by spaces and then ok,cancel. 我想将样本按钮放在左下角,然后是空格,然后确定,取消。

How do i achieve this? 我如何实现这一目标?

This is the way the Eclipse About dialog does this: 这是Eclipse About对话框执行此操作的方式:

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);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM