Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » setWidth for ToolItem in ToolBar does not function as expected
setWidth for ToolItem in ToolBar does not function as expected [message #445450] Fri, 05 November 2004 22:26 Go to next message
Eclipse UserFriend
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 #445451 is a reply to message #445450] Fri, 05 November 2004 22:42 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: martin_hulth.hotmail.com

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
Re: setWidth for ToolItem in ToolBar (code revised) [message #445474 is a reply to message #445451] Sat, 06 November 2004 00:15 Go to previous message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
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
Previous Topic:Color and dispose
Next Topic:Flat Look Design
Goto Forum:
  


Current Time: Mon Sep 23 06:56:58 GMT 2024

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

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

Back to the top