How to layout OK & Cancel button like in Preference dialog [message #465967] |
Tue, 27 December 2005 12:15 |
|
Hi all,
I need to layout OK and Cancel buttons just like in Preference dialog
where the buttons are aligned right with a separator above them. I manage
to align the buttons but I fail to make separator span the entire area.
Here's my code:
//The following methods is overidden from MessageDialog class
protected void createButtonsForButtonBar(Composite parent)
{
Label separator = new Label(parent,SWT.SEPARATOR | SWT.HORIZONTAL);
GridData data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalSpan = 2;
separator.setLayoutData(data);
super.createButtonsForButtonBar(parent);
}
Any help would be greatly appreciated.
Thanks in advanced.
Setya
|
|
|
|
Re: How to layout OK & Cancel button like in Preference dialog [message #465979 is a reply to message #465971] |
Wed, 28 December 2005 02:28 |
|
Thanks for the response,
> the problem is that the parent composite itself does not span the width
> of the dialog. the easiest way to get a separator to span the whole
> dialog appears to be to add it at the bottom of the dialog area when you
> override createDialogArea(Composite parent).Thanks for the response,
I've tried your suggestions before and yes the separator can span the
whole dialog, but since the OK & Cancel buttons sit at the bottom of the
dialog the separator won't sit exactly above them.
I was wondering if someone can point me to the source of various dialogs
in Eclipse itself that have this kind of layout (new package dialog, new
interface dialog, etc).
Regards,
Setya
|
|
|
|
Re: How to layout OK & Cancel button like in Preference dialog [message #465988 is a reply to message #465981] |
Wed, 28 December 2005 09:11 |
|
Jeremy Dowdall wrote:
> in createDialogArea(Composite parent), did you add the separator
> directly to parent?
> ie:
> public Control createDialogArea(Composite parent) {
> Composite composite = (Composite) super.createDialogArea(parent);
> composite.setLayoutData(new GridData(GridData.FILL_BOTH));
> Label lbl = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL);
> lbl.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
> return composite;
> }
Yes, the separator spans the whole dialog horizontally, but its vertical
distance with OK & Cancel buttons is too far.
Regards,
Setya
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03734 seconds