Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How to layout OK & Cancel button like in Preference dialog
How to layout OK & Cancel button like in Preference dialog [message #465967] Tue, 27 December 2005 12:15 Go to next message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
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 #465971 is a reply to message #465967] Tue, 27 December 2005 16:15 Go to previous messageGo to next message
Jeremy Dowdall is currently offline Jeremy DowdallFriend
Messages: 48
Registered: July 2009
Member
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).
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 Go to previous messageGo to next message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
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 #465981 is a reply to message #465979] Wed, 28 December 2005 04:55 Go to previous messageGo to next message
Jeremy Dowdall is currently offline Jeremy DowdallFriend
Messages: 48
Registered: July 2009
Member
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;
}


Setya wrote:
> 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 Go to previous messageGo to next message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
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
Re: How to layout OK & Cancel button like in Preference dialog [message #466000 is a reply to message #465988] Wed, 28 December 2005 15:33 Go to previous messageGo to next message
Jeremy Dowdall is currently offline Jeremy DowdallFriend
Messages: 48
Registered: July 2009
Member
interesting... this method is spacing them perfectly on GTK; please let
me know what system you're running so I make sure to fix my dialogs
before releasing there.

thanks!


Setya wrote:
> 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
>
Re: How to layout OK & Cancel button like in Preference dialog [message #466021 is a reply to message #466000] Thu, 29 December 2005 02:27 Go to previous message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
> interesting... this method is spacing them perfectly on GTK; please let
> me know what system you're running so I make sure to fix my dialogs
> before releasing there.

> thanks!

Eclipse 3.1.0, build:I20050627-1435 on WinXP

Regards,

Setya
Previous Topic:SWT and Antialiasing
Next Topic:Can I change the row color in the property views?(IPropertySource)
Goto Forum:
  


Current Time: Thu Dec 26 18:27:11 GMT 2024

Powered by FUDForum. Page generated in 0.03734 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top