I need a button to be constantly placed at the bottom left corner of my JFace dialog even on re size of dialog.
I have overridden the 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:
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);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With