我需要一个按钮不断放在我的JFace对话框的左下角,即使是对话框的大小。
我已经覆盖了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);
}
我想将示例按钮放在左下角,然后是空格,然后确定,取消。
我如何实现这一目标?
答案 0 :(得分:8)
这是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);
}