Getting panel width and height in GWT
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 Root开发者_StackOverflow社区LayoutPanel (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?
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.
精彩评论