当我在按钮栏中的对话框两端创建一个复选按钮和按钮时,它默认创建得很好,但是当我拖动或调整对话框大小时,复选按钮会从对话框的左端移开。当我调整对话框大小时,我应该如何防止它移动。这就是我覆盖按钮栏的方式。
@Override
protected void createButtonsForButtonBar(Composite parent) {
super.createButtonsForButtonBar(parent);
((GridLayout) parent.getLayout()).numColumns = ((GridLayout) parent.getLayout()).numColumns+2;
GridData checkData = new GridData(SWT.LEFT,
SWT.BOTTOM,true,true);
GridData labelData = new GridData(SWT.CENTER,
SWT.CENTER,true,true);
GridData closeLayoutData = new GridData(SWT.RIGHT,
SWT.BOTTOM,true,true);
parent.setLayoutData(closeLayoutData);
Button close = getButton(IDialogConstants.CANCEL_ID);
close.setText("Close");
close.setLayoutData(closeLayoutData);
close.setParent(parent);
final Button checkButton = new Button(parent, SWT.CHECK);
checkButton.setText("View All schedules");
checkButton.setSelection(false);
checkButton.setLayoutData(checkData);
checkButton.setParent(parent);
checkButton.moveAbove(close);
checkButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (checkButton.getSelection()) {
treeViewer.setFilters(new ViewerFilter[] { new ExistingExpiredScheduleFilter() });
} else {
treeViewer.setFilters(new ViewerFilter[] { new ExistingScheduleFilter() });
}
}
});
Label label = new Label(parent,SWT.HORIZONTAL);
label.setLayoutData(labelData);
label.setParent(parent);
label.moveAbove(close);
}