setWidth for ToolItem in ToolBar does not function as expected [message #445450] |
Fri, 05 November 2004 17:26  |
Eclipse User |
|
|
|
Originally posted by: martin_hulth.hotmail.com
Background:
I have a vertical ToolBar with three items in it. I try to set the width
of all ToolItems equal to the maximum width using two for loops, and
they always revert back to the default minimum width.
Example:
Add an item to a toolbar and set the width, then print the width to test
if it was set...
// composite declared previously
....
ToolBar toolbar = new ToolBar (composite, SWT.VERTICAL);
ToolItem item = new ToolItem (toolbar , SWT.NONE);
addProtocolItem.setText ("Item");
addProtocolItem.setWidth(60);
System.out.println(addProtocolItem.getWidth());
....
This outputs "33" instead of "60". setWidth() does not behave as
expected. Any insight is appreciated.
Thank you.
Martin
|
|
|
|
Re: setWidth for ToolItem in ToolBar (code revised) [message #445474 is a reply to message #445451] |
Fri, 05 November 2004 19:15  |
Eclipse User |
|
|
|
Martin,
ToolItem.setWidth(int) only applies to ToolItems of type SWT.SEPARATOR.
(ToolItem's javadoc was just updated last week to make this more clear).
Grant
"Martin Hulth" <martin_hulth@hotmail.com> wrote in message
news:cmgvk4$5mi$1@eclipse.org...
> Martin Hulth wrote:
>
> > Background:
> >
> > I have a vertical ToolBar with three items in it. I try to set the width
> > of all ToolItems equal to the maximum width using two for loops, and
> > they always revert back to the default minimum width.
> >
> >
> > Example:
> >
> > Add an item to a toolbar and set the width, then print the width to test
> > if it was set...
> >
> > // composite declared previously
> > ...
> > ...
> > ToolBar toolbar = new ToolBar (composite, SWT.VERTICAL);
> >
> > ToolItem item = new ToolItem (toolbar, SWT.NONE);
> > item.setText ("Item");
> > item.setWidth(60);
> > System.out.println(item.getWidth());
> > ...
> >
> >
> > This outputs "33" instead of "60". setWidth() does not behave as
> > expected. Any insight is appreciated.
> >
> >
> > Thank you.
> >
> > Martin
|
|
|
Powered by
FUDForum. Page generated in 0.05436 seconds