Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the height of a GWT object in pixels?

Tags:

gwt

How do I get the height of a GWT object in pixels? I am trying to find a getHeight method or something similar..

like image 511
Ztyx Avatar asked Mar 26 '10 10:03

Ztyx


2 Answers

You are probably looking for getOffsetHeight() (inherited by every part of the UI from UiObject):

Gets the object's offset height in pixels. This is the total height of the object, including decorations such as border, margin, and padding.

There's also the getClientHeight() from Element:

Returns the inner height of an element in pixels, including padding but not the horizontal scrollbar height, border, or margin.

You can access the underlying Element of every UiObject (meaning Widgets, etc) via the getElement() method.

Be sure to check that the item is visible at the time the size is read, else you will get 0.

like image 87
Igor Klimer Avatar answered Nov 08 '22 08:11

Igor Klimer


There is indeed getOffsetHeight() but that just gives the total height of the object, including decorations such as border and padding, but not margin.1 You can get the element and use getClientHeight() and it gives the inner height of an element in pixels, including padding but not the horizontal scrollbar height, border, or margin.

So getting the full rendered height including margins don't seem to be possible.

like image 44
liftarn Avatar answered Nov 08 '22 09:11

liftarn