2
votes

I want to draw a gradient to a canvas and add it to an AbsolutePanel, thus i need width and height of absolutePanel to define gradient vector. But event if I add AbsolutePanel to RootLayoutPanel (via the north-widget of a DockPanel, which width set to 100%) and call a method setGradient() after, i still get 0 for width and height. How can i get the dimensions of the panel?

1

1 Answers

4
votes

Use getOffsetWidth() and getOffsetHeight() methods. The doc is here:

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

The methods are defined in UiObject, so common for all widgets.