Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How can i get the real size of a Component?
How can i get the real size of a Component? [message #461469] Sun, 25 September 2005 14:30 Go to next message
Sean is currently offline SeanFriend
Messages: 20
Registered: July 2009
Junior Member
When i use a getSize() method it returns zero. How can is get it real size?

Thanks

Can any one help me?

Sean
Re: How can i get the real size of a Component? [message #461470 is a reply to message #461469] Sun, 25 September 2005 14:50 Go to previous messageGo to next message
Joe is currently offline JoeFriend
Messages: 12
Registered: July 2009
Junior Member
Hi Sean!

Try
component.getBounds();
Re: How can i get the real size of a Component? [message #461471 is a reply to message #461470] Sun, 25 September 2005 17:12 Go to previous messageGo to next message
Benjamin Pasero is currently offline Benjamin PaseroFriend
Messages: 337
Registered: July 2009
Senior Member
Joe wrote:
> Hi Sean!
>
> Try component.getBounds();
>
>
>
You will get zero for getSize, getLocation and getBounds if the
component has not yet been layouted. You should call computeSize.

Ben
Re: How can i get the real size of a Component? [message #461473 is a reply to message #461471] Sun, 25 September 2005 23:51 Go to previous messageGo to next message
Sean is currently offline SeanFriend
Messages: 20
Registered: July 2009
Junior Member
> Joe wrote:
>> Hi Sean!
>>
>> Try component.getBounds();
>>
>>
>>
> You will get zero for getSize, getLocation and getBounds if the
> component has not yet been layouted. You should call computeSize.
>
> Ben

Yes, Ben is right. When i called the component's setSize() method both
getSize() and getBounds() works,but it got zero when you do not called the
setSize() method.

For more: is computeSize method a standard method of a component?
Re: How can i get the real size of a Component? [message #461475 is a reply to message #461473] Mon, 26 September 2005 04:18 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 97
Registered: July 2009
Member
"Sean" <bjsk-pkm@163.com> wrote in message
news:dh7d73$595$1@news.eclipse.org...
> Yes, Ben is right. When i called the component's setSize() method both
> getSize() and getBounds() works,but it got zero when you do not called the
> setSize() method.
>
> For more: is computeSize method a standard method of a component?

Yes. But it might not work as you may intend.
Just try out!

>
>
Re: How can i get the real size of a Component? [message #461477 is a reply to message #461475] Mon, 26 September 2005 06:18 Go to previous message
Benjamin Pasero is currently offline Benjamin PaseroFriend
Messages: 337
Registered: July 2009
Senior Member
Carefully read the API of computeSize. You pass in two arguments, for
a width- and a height-hint. If both args are SWT.DEFAULT, the preferred
width and height is calculated with no constraint.

Ben
> "Sean" <bjsk-pkm@163.com> wrote in message
> news:dh7d73$595$1@news.eclipse.org...
>
>> Yes, Ben is right. When i called the component's setSize() method both
>> getSize() and getBounds() works,but it got zero when you do not called the
>> setSize() method.
>>
>> For more: is computeSize method a standard method of a component?
>>
>
> Yes. But it might not work as you may intend.
> Just try out!
>
>
>>
>
>
>
Previous Topic:Table editor throws widget disposed error. Please help
Next Topic:GUI test tools for SWT
Goto Forum:
  


Current Time: Thu Sep 19 08:43:25 GMT 2019

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

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

Back to the top